Shell script cut the beginning and the end of a file -


so have file , i'd cut first 33 lines , last 6 lines of it. trying whole file in cat command (cat file) , use "head" , "tail" commands remove parts, don't know how so. eg (this idea)

cat file - head -n 33 file - tail -n 6 file 

how supposed this? possible "sed" (how)? in advance.

this want:

$ tail -n +34 file | head -n -6 

see tail

-n, --lines=k output last k lines, instead of last 10; or use -n +k output lines starting kth

and head

-n, --lines=[-]k print first k lines instead of first 10; leading '-', print last k lines of each file

man pages.

example:

$ cat file 1 2 3 4 5 6 7 8  $ tail -n +4 file | head -n -2 4 5 6 

notice don't need cat (see uuoc).


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -