The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To remove new line character shihabvk UNIX for Advanced & Expert Users 7 06-18-2009 08:44 AM
sed remove last 10 characters of a line start from 3rd line minifish Shell Programming and Scripting 7 03-26-2008 04:42 PM
SED help (remove line::parse again::add line) Malumake Shell Programming and Scripting 6 10-24-2007 06:02 PM
remove line 1 and save it.... happyv Shell Programming and Scripting 10 12-20-2006 02:32 AM
Remove header(first line) and trailer(last line) in ANY given file madhunk Shell Programming and Scripting 2 03-13-2006 03:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-27-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
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!
  #2 (permalink)  
Old 01-27-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Code:
sed -n -e '16,980p' file
  #3 (permalink)  
Old 01-27-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
Thank you Vino

What about 20 lines from bottom up. And the files' line-number are randomly come in. sometimes, 850, 900, 700 ....
  #4 (permalink)  
Old 01-27-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
  
 

Join Date: Dec 2005
Location: London
Posts: 222
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 (permalink)  
Old 01-28-2006
gauravgoel gauravgoel is offline
Registered User
  
 

Join Date: Dec 2005
Location: India
Posts: 218
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 (permalink)  
Old 01-28-2006
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,957
Code:
lines=$((`sed -n '$=' samplefile` - 20)); awk '{ if(NR > 15 && NR < '$lines') print}' samplefile
  #7 (permalink)  
Old 01-30-2006
bobo bobo is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 148
Thank you much!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0