Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove line

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
Hello,
Suppose I have the following txt file:

Line 1
Line 2

With what script function can I remove the first line?
 
Hi BIS,

a very simple solution is the following:

$ sed 1d your_file > your_new_file

The redirection to a new file will give you the old file without line 1.

mrjazz [pc2]
 
sed -e '1d' myFile.txt vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
What if the file is being used by a process and you can't overwrite the file. I need to search for a string within the file and delete all occurances of that string. Then save the file without overwriting the whole thing.
 
If the file is locked by another process, then u must wait till the file handle is released..

Regds,

- Hemant
Networking and Systems Integration Group
Satyam Computer Services Ltd
 
Many many thanks to all of you. This was what was needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top