Hi all
I need to remove the first 21 lines from a text file, how would I go about this.
It doesn't need to be done in place, so what I tried at first was a while loop to read the first 21 lines, ignore them, then output the rest to another file, but it just seems to throw it into an infinite loop.
Anyone have an idea how I can do this?
I've tried this (keep in mind that my bash experience is limited so there are probably a million things wrong with this, feel free to correct it, but if you could please explain what I have messed up that would help me not to repeat these mistakes in the future):
Code:
line = 1
while read line do
if [line <= 21]
then echo $ line && $line++
fi
else
{
echo line >> bar.txt
line++
}
done < foo.txt
Also I don't know if the "while read line" causes an increment of line value with every iteration (i.e. do I need something like line++ or is it sorted out for me)
I'm sure there is a simple solution for this, I just lack the bash experience to figure it out.
Also anyone have any recommendations for reading up on bash script, something that starts with syntax for while, for, if etc. and works up to more complex stuff?