input string
prashant@prashant:~/Desktop$ xyz /123/ {print } abc.txt
after using awk command to strip on above input string I should get below
output string
xyz /123/ {print } abc.txt
input string
prashant@prashant:~/Desktop$ xyz /123/ {print } abc.txt
after using awk command to strip on above input string I should get below
output string
xyz /123/ {print } abc.txt
Try:
awk -F'$' '{print $2}' <<<"$str"
or if you don't want a space from the beginning try:
awk -F'xyz' '{print FS $2}' <<<"$str"
where the input string is stored in str
variable as following:
str="prashant@prashant:~/Desktop$ xyz /123/ {print } abc.txt"
-F'$'
defines the Field Separator to $
print $2
prints the second filed $2
with $
as field separator between them.FS
in second command will prints the entry of Field Separator which is defined to xyz
.awk '{sub(/prashant\@prashant\:\~\/Desktop\$ /,"");print}' <<<"$str"
and don't forget please mark the answer as accepted. thanks
– αғsнιη
Jan 7 '15 at 13:38