how do you view the last 15 lines of a unix f

Emachines Em250-1915 - 10.1
February 27, 2011 at 21:24:27
Specs: Windows XP, 1GB
someone help me how to view the last 15 lines of a file in unix

See More: how do you view the last 15 lines of a unix f

Report •


#1
February 27, 2011 at 22:11:22
One way to use the tail command:

tail -15 myfile.txt

another way using sed - less efficient:
# get number of lines in file
len=$(wc -l < myfile.txt)
# subtract 15
((len-=15))
# last 15 lines of file
sed -n ''"${len}"',$p' myfile.txt


Report •
Related Solutions


Ask Question