remove first line in bash
Solution 1:
One-liners in reverse order of length, portable unless noted.
sed
(needs GNU sed
for -i
):
sed -i 1d file
ed
(needs e.g. bash
for $'...'
expansion and here string):
ed file <<< $'1d\nw\nq'
awk
:
awk NR\>1 infile > outfile
tail
:
tail -n +2 infile > outfile
read
+ cat
:
(read x; cat > outfile) < infile
bash
built-ins:
while IFS= read -r; do ((i++)) && printf %s\\n "$REPLY" >> outfile; done < infile
Solution 2:
$ tail -n +2 <<< $'1\n2\n3'
2
3