Extract particular words froma file.

February 2, 2010 at 02:41:22
Specs: Unix
I have a file having the data as below:

satya ranjon [ Analyst ] 23287_FS
Mark Lauren [ Delivery manager ] 36725_FS
Himanshu [ Manager ] 1276_FS

i need to extract the names only. i.e i need to remove all the words/characters after the first occurrence of the character "[". Is it possible by sed or in other ways we can do.


See More: Extract particular words froma file.

Report •

February 2, 2010 at 10:10:08
In awk, change the field separator to [ and print the first field:


awk ' BEGIN { FS="[" } {
print $1
} ' datafile.txt

Report •
Related Solutions

Ask Question