Wednesday 15 January 2014

bash - text file split based on regular expressions -


How can I divide a text file into several text files (in Linux Commandline-Bash environment) based on a reggae expression? Am Expression is a part of a line? Example:

original.txt:

  1, Johnny auspicious, 91240, ***** 2, non-repeated, 34755, *** 4 , Mary bad credit, 92323, * 2, which is 2 non-Frequent D, 34755, 223, 3 frequent, 34755, *** After the partition of the files:   

91240.txt:

  1, Johnny Good, 91240, *****   

34755.txt:

  2, which is non-recurring, 34755, *** 2, which is 2 non-freewants, 34755, *** 223, which is 3 frequencies, 34755, ***.   

92323.txt:

  4, my bad credit, 92323, *   

thanks for your response .

  awk -F, '{print> $ 3 ".txt"} 'your_file    

No comments:

Post a Comment