Sunday, 15 January 2012

awk - Split a text file based on delimiter using linux command line -


I have a file with the following lines of text:
  Jeremy, Thomas, 123 Peter, Paul, 456 Jack, Jill, 789   

I would like to delete all the data except the center item, for example, ending with a file containing: < Pre> Thomas Paul jill

I have tried so many strange patterns that my brain is exploding. Any help would be appreciated.

Try awk :

  Awk -F '[[: space:]] *, [[space:]]' '{print $ 2}' input.txt    

No comments:

Post a Comment