Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
Can anyone tell me how I can remove the top 3 lines from a text file using unix shell scripting. I've been using the korn shell but can't work out how to do it.
Cheers,
Andy

hi,
maybe my script will help you-- cut here -----
#!/bin/sh#get lines of the file
lines=$(grep -c "" $1)#sub 3
li=$(($lines-3))#print lines except first three
tail -n $li $1-- cut here -----
first parameter is the filename to cut the first 3 lines
example (script is called cutfirst3.sh):
sh cutfirst3.sh textfile.txt > newtextfile.txt
in the "newtextfile.txt" the first 3 lines are removed
regards

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |