Linux: how to get or delete first line of a file


Linux: how to get first line of a file

Example:

[root@tutorialspots ~]# head -1 /root/ok/ok2.txt
375584066214

Linux: how to get last line of a file

Example:

[root@tutorialspots ~]# tail -n -1 /root/ok/ok2.txt
369178446515

Linux: how to delete first line of a file

Example:

echo "$(tail -n +2 /root/ok/ok2.txt)" > /root/ok/ok2.txt

or

echo -e "$(sed '1d' /root/ok/ok2.txt)" > /root/ok/ok2.txt

Leave a Reply