how do i modify the following:
echo "jaba law welcome no jaba law sorry now jaba law" | awk '{s+=gsub(/jaba law/,"jaba law")} END {print s}'
so that it shows me the actual phrase it found matching the strings i specified?
something like:
jaba law jaba law jaba law
RudiC
2
Not sure this will work on all sed versions, but try (inverting the meaning of fields and field separators):
$ echo "jaba law welcome no jaba law sorry now jaba law" | awk 'BEGIN {FS=OFS="jaba law"} {$2=" ";$3=" "}1'
this could work. how can i use it on something lke this.
echo "jabalaw--sony--4444 marykate--toshiba--244444 mark--sanyo--3334343"
notice how each is separated by a space. how do i grab the section that's for marykate and then show only that section?
meaning,
if i run:
echo "jabalaw--sony--4444 marykate--toshiba--244444 mark--sanyo--3334343" | awk or sed or egrep "marykate"
i would like to get the whole thing thats just for marykate, so in this case it'll be:
marykate--toshiba--244444
another example:
echo "jabalaw--sony--4444 marykate--toshiba--244444 mark--sanyo--3334343" | awk or sed or egrep "mark"
in this case, i'd like to get back:
mark--sanyo--3334343
awk '{ for(N=1; N<=NF; N++) if ($N ~ P) print $N }' P="^mark-"
RudiC
5
This is entirely different from your first request! Nevertheless, try
$ echo "jabalaw--sony--4444 marykate--toshiba--244444 mark--sanyo--3334343" | awk '/^mark/' RS=" "
mark--sanyo--3334343