what is the easiest way to "knock off" the just the first line of a file in bash.

I have a data file and I fix the first entry and then delete the entry.  

My problem is that I do not really trust sed on solaris boxes.  I assume that if it works in solaris, it will work in linux  ( ksh & bash ).

what is an easy way to get rid of the first line in a file in solaris ( and should also work in linux and hopefully aix  ).

Cross platform is the key

Who is Participating?
woolmilkporcConnect With a Mentor Commented:
Why wouldn't you trust sed?

sed "1d" filename

wil work on any platform.

With GNU sed (Linux) you can even change the file "in place":

sed -i "1d" filename.

Without GNU sed you'll have to use (preserving permissions):

cp -p filename filename.$$; sed "1d" filename > filename.$$; mv filename.$$ filename; rm filename.$$

awk is always an anlternative, equally available on any platform:

awk 'NR!=1 {print}' filename

To replace the original file:

cp -p filename filename.$$; awk 'NR!=1 {print}' filename > filename.$$; mv filename.$$ filename; rm filename.$$



tail -n +2 file_name
TIMFOX123Author Commented:
Let me see if I understand this.

If I want to use the cross platform script I need to do someting like this for sed ?  

sed "1d" fixes2 > fixes3;  cp fixes3 fixes2  

Seems messy.

If there is a better way I am all ears !!!

TIMFOX123Author Commented:
thank you

it worked

I used sed
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.