LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   unix shell script:How to delete the first line in a file?? (http://www.linuxquestions.org/questions/programming-9/unix-shell-script-how-to-delete-the-first-line-in-a-file-108522/)

rche3252 10-25-2003 08:58 PM

unix shell script:How to delete the first line in a file??
 
How to delete the first line in a file???

thanks

david_ross 10-26-2003 06:48 AM

To remove the first line from the file in "$file" then you could use:
tail $file -n`echo \`grep -c '' $file\`-1|bc`

Hko 10-26-2003 07:17 AM

Code:

mv myfile.txt myfile.tmp
sed 1d myfile.tmp > myfile.txt
rm myfile.tmp


your_shadow03 03-03-2010 07:01 AM

What if file is busy(say it is a log being accesed?)

druuna 03-03-2010 07:11 AM

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.

karthi_27 03-03-2010 07:16 AM

There is no need for script here . just do it using sed,

Code:

sed -i 1d file

ghostdog74 03-03-2010 07:32 AM

i noticed this is very old thread, but nonetheless,
Code:

more +2 file > newfile


All times are GMT -5. The time now is 12:04 PM.