The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting lines from a file Nirgude07 UNIX for Advanced & Expert Users 11 07-01-2009 02:09 PM
Deleting lines in a file reachsamir Shell Programming and Scripting 2 05-29-2007 11:17 AM
Deleting last 2 lines from the file. videsh77 Shell Programming and Scripting 4 04-06-2007 01:14 PM
Deleting Lines from .csv file 009satya Shell Programming and Scripting 3 11-14-2006 03:41 AM
Urgent help required in deleting a line without opening a file usinga shell script naan Shell Programming and Scripting 6 07-20-2006 03:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-21-2007
toms toms is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 7
Deleting lines inside a file without opening the file

Hi,

Just consider there are around 10 lines in a file. Now is it possible to delete the first 2 lines in the file without opening the file. No matter whatever the content of the file is, I just wanna delete the first 2 lines without opening the file. Is that possible? If so, please help me out.

Thanks,
Toms
  #2 (permalink)  
Old 09-21-2007
zedex zedex is offline
Registered User
  
 

Join Date: Feb 2007
Location: india,mumbai
Posts: 138
use sed

you can try this ...

sed -n '1,2!p' filea > file2 ; mv file2 file1
  #3 (permalink)  
Old 09-21-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,507
Code:
sed -i '1,2d' file
  #4 (permalink)  
Old 09-24-2007
toms toms is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 7
Smile Thanks

Thanks!!! Both the options are working fine....

Toms
Sponsored Links
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 09:28 PM.


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