How to remove first 100 line in a file?

Hello,

I want to find a way to remove first few line in a file in linux.
I know sed -e but the problem is that I cant redirect my output to some file and rename it because this file is created by java code and point to Inode rather than file name.

Please suggest me a single line command that will erase first 100 lines of file.

Thanks in advance,
Y

You can use sed with in-place editing:

sed -i -e '1,100d' file

Thanks a lot!!

---------- Post updated at 03:22 PM ---------- Previous update was at 01:47 PM ----------

One more question, it works well on Linux but doesnt work on Solaris:confused:

Any idea about solaris??

Appretiate your help

In-place editing is a feature of GNU sed, and sadly not available on most other Unices. Either use the GNU version or give Perl a try:

perl -i -ne 'print if $.>100' file

Thank you !!
It worked fine :slight_smile:

Appretiate you quick response:b:

A solution using awk, just to make the group complete :wink:
awk '{ if(NR > 4) print $0; }' input > output

---------- Post updated at 03:33 AM ---------- Previous update was at 03:31 AM ----------

Should be 100 instead of 4, of course. I just didn't find a file so large to give it a quick shot...
Btw, an edit function would be really nice.

Let's not forget about:

d100d

in Vi. :slight_smile:

Note: Yes, I do know the OP did not want to actually open the file. Just putting it out there for the archives.