![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| retrive value from a file | satish@123 | Shell Programming and Scripting | 7 | 05-17-2008 05:57 AM |
| to retrive data that appear only once in a file. | anibu | Shell Programming and Scripting | 1 | 10-26-2007 07:54 AM |
| Retrive deleted file's info | asmita | UNIX for Advanced & Expert Users | 4 | 03-26-2007 10:36 PM |
| help to retrive data from log file | d_swapneel14 | Shell Programming and Scripting | 5 | 07-06-2006 01:57 AM |
| need help appending lines/combining lines within a file... | mr_manny | Shell Programming and Scripting | 2 | 01-06-2006 02:45 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
retrive lines from a file using AWK command
Dear friends,
please tell me how to get some required lines from a file and write to another file using AWK command. i.e., if a file contains, abcdefghigk 12345 lmnopqrstuv 678910 wxyz please tell me how to get lines(line count is always 2 and it's contineous) mentioned in blue colour from above file and write the same to another file. thanks in advance, swamymns |
| Forum Sponsor | ||
|
|
|
|||
|
Are they always the second and third lines of the input file? If so, something like:
Code:
awk 'NR==2 || NR ==3' inputfile > outputfile Code:
awk '/12345/ { print ; getline; print }' inputfile > outputfile
|
|||
| Google UNIX.COM |