how to extract data between a matched strings in a file
Hi All,
I got stuck when i am trying to extract the data between a matched strings in a file which contains a million records with \t is the field seperator. i am getting that matched_string in only one particular field(5 field). ex: fiel_name:siva.txt record_1: a b c d _bb_vid:dfndjgddgn~~~ e f g record_2: h g e f _bb_vid:kdjgfkdhjk~~~ k h d like this lakhs of records will be there. i want add the result set into end of the file with \t as field seperator. estimated_out_put: record_1: a b c d _bb_vid:dfndjgddgn~~~ e f g dfndjgddgn record_2: h g e f _bb_vid:kdjgfkdhjk~~~ k h d kdjgfkdhjk please help me guys. |
You use awk script to do that. Each field would be variable. So you put the field again in the end.
Read more about awk by 'info awk'. |
will you please elaborate with an example. i am new to linux.
|
Quote:
You can VERY EASILY find many awk examples (as well as examples using other tools), if you tried a brief Google search for something very obvious, like "how to get data between two strings in linux". We are happy to help you, but you are going to have to show some effort of your own. Post what you've done/tried, or post one of the examples you found and tell us what you're confused about. But we aren't going to look things up for you. |
awk manual
You will need to look at the FS (field separator) variable, would suggest setting to : and ~ Then simply append a tab and the appropriate field to the end of the line (referenced by $0) |
All times are GMT -5. The time now is 09:25 PM. |