Hi Guys,
I have a file like this:
wwwe 1 ioie ewew yyy uuu 88
erehrlk 4 ihoiwhe lkjhassad lkhsad yyy mmm 45
jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe yyy ggg 77
I want to remove everything after "yyy" and including "yyy" from each line in the file.
So I want:
wwwe 1 ioie ewew
erehrlk 4 ihoiwhe lkjhassad lkhsad
jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe
How do I do this?
Thanks.
Scott
2
Hi.
You can do it with sed:
$ cat file1
wwwe 1 ioie ewew yyy uuu 88
erehrlk 4 ihoiwhe lkjhassad lkhsad yyy mmm 45
jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe yyy ggg 77
$ sed "s/yyy.*//" file1
wwwe 1 ioie ewew
erehrlk 4 ihoiwhe lkjhassad lkhsad
jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe
# I suppose more accurate would be
sed "s/\wyyy.*//" file1
# or
sed "s/ *yyy.*//" file1
You can use this to get everything before the pattern yyy.
Here I used yyy pattern as field seperator.
cat file|awk -F 'yyy' '{print $1}'
Thanks