![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 | Thread Starter | Forum | Replies | Last Post |
| sed remove last 10 characters of a line start from 3rd line | minifish | Shell Programming and Scripting | 7 | 03-26-2008 01:42 PM |
| SED help (remove line::parse again::add line) | Malumake | Shell Programming and Scripting | 6 | 10-24-2007 02:02 PM |
| remove line 1 and save it.... | happyv | Shell Programming and Scripting | 10 | 12-19-2006 11:32 PM |
| Remove header(first line) and trailer(last line) in ANY given file | madhunk | Shell Programming and Scripting | 2 | 03-13-2006 12:36 PM |
| To remove new line character | shihabvk | UNIX for Advanced & Expert Users | 6 | 08-18-2005 12:02 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Remove first 15 line
Friends,
I have a file with 1000 lines. How can I remove the first 15 lines and 20 lines from BOTTOM of the file UP. Many thanks! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
sed -n -e '16,980p' file |
|
#3
|
|||
|
|||
|
Thank you Vino
What about 20 lines from bottom up. And the files' line-number are randomly come in. sometimes, 850, 900, 700 .... |
|
#4
|
|||
|
|||
|
wc -l filename | awk '{ printf "%d",$1-20'} | xargs -I {} head -{} filename
or sed -n "1,$(($(wc -l file1 | awk '{print $1'})-20)) p" filename try the second one in ksh |
|
#5
|
|||
|
|||
|
try the following
ex file_name :1,5d (specify the range of lines to delete) :wq! specify the range correctly to delete the lines. cheers, Gaurav |
|
#6
|
|||
|
|||
|
Code:
lines=$((`sed -n '$=' samplefile` - 20)); awk '{ if(NR > 15 && NR < '$lines') print}' samplefile
|
|
#7
|
|||
|
|||
|
Thank you much!
|
|||
| Google The UNIX and Linux Forums |