Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
10-25-2003, 09:58 PM
|
#1
|
LQ Newbie
Registered: Oct 2003
Posts: 2
Rep:
|
unix shell script:How to delete the first line in a file??
How to delete the first line in a file???
thanks
|
|
|
10-26-2003, 07:48 AM
|
#2
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
To remove the first line from the file in "$file" then you could use:
tail $file -n`echo \`grep -c '' $file\`-1|bc`
|
|
|
10-26-2003, 08:17 AM
|
#3
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536
Rep:
|
Code:
mv myfile.txt myfile.tmp
sed 1d myfile.tmp > myfile.txt
rm myfile.tmp
|
|
|
03-03-2010, 08:01 AM
|
#4
|
Senior Member
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,466
Rep:
|
What if file is busy(say it is a log being accesed?)
|
|
|
03-03-2010, 08:11 AM
|
#5
|
LQ Veteran
Registered: Sep 2003
Posts: 10,532
|
Hi,
I told you already that this cannot be done! ( In this, merged, thread).
Also: Did you try the solution I offered at the end of the thread?????
PS: Do _not_ repeat the same question in different forms. This is the third fourth time you ask the same question.
|
|
|
03-03-2010, 08:16 AM
|
#6
|
LQ Newbie
Registered: Mar 2010
Posts: 6
Rep:
|
There is no need for script here . just do it using sed,
|
|
|
03-03-2010, 08:32 AM
|
#7
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
i noticed this is very old thread, but nonetheless,
Code:
more +2 file > newfile
|
|
|
All times are GMT -5. The time now is 07:46 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|