|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How do you specific lines in a file?
I'm looking to show specific lines (eg. 20 through 40) of a series of files in the directory. How do I do this?
|
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
You could use sed. I believe the syntax is as follows: Code:
sed -n '20,40p' file_name For files in a directory: Code:
cd directory_where_files_are for file_name in *; do sed -n '20,40p' file_name done |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Try.. Code:
awk 'FNR>=20 && FNR<=40' file* |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deleting specific lines in a file | asanchez | Shell Programming and Scripting | 5 | 07-27-2011 03:41 AM |
| Extracting specific lines of data from a file and related lines of data based on a grep value range? | Wynner | Shell Programming and Scripting | 3 | 05-18-2011 11:35 AM |
| Substitute specific lines with lines from another file | rahmathulla | Shell Programming and Scripting | 1 | 01-11-2009 10:45 AM |
| how to display specific lines of a specific file | raidkridley | UNIX for Dummies Questions & Answers | 2 | 10-15-2008 02:46 PM |
| overwrite specific lines in a file | csecnarf | Shell Programming and Scripting | 7 | 05-13-2008 11:01 AM |
|
|