to keep the first 10 lines of "file":
head -10 file
to skip the first 10 lines of "file":
tail +11 file
to skip the last 10 lines of "file":
head -n -10 file
to keep the last 10 lines of "file":
tail -10 file
to print lines 11-20 of a file:
sed -e 1,10d -e 20q file
head
head -c 50m
-n, --lines=[-]N print the first N lines instead of the first 10; with the leading `-', print all but the last N lines of each file -c, --bytes=[-]N print the first N bytes of each file; with the leading `-', print all but the last N bytes of each file
SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg.
> > Is there any ready-made tool to print lines from a file *after* a given > > line number?
Well, tail does that just fine; to skip the first 10 lines of "file":
tail +11 file
Another option is sed:
sed 1,10d file
The sed approach generizes better; to print lines 11-20 of a file:
sed -e 1,10d -e 20q file
-Ken Pizzini
ff -l . | cut -c1-12,29-
ls -l | cut -c30-42,56-
head /usr/X11R6/lib/X11/rgb.txt | cut -f 3 # X ls -l | cut -d ' ' -f 1,9 # not working!
-c list The list following -c specifies character posi- tions (for instance, -c1-72 would pass the first 72 characters of each line).
![]() | |
Starting from 1. |
-f, --fields field-list Print only the fields listed in field-list. Fields are sepa- rated by a TAB by default.
-d, --delimiter delim For -f, fields are separated by the first character in delim instead of by TAB.
![]() | |
-d 'x' would normally always follows -f, |
Newsgroups: comp.unix.shell
> > I need to eliminate the second column of a certain file. > > Sounds like a job for cut.
Only if the columns are delimited by *exactly one* space. If they look like:
Margolin Barry Other stuff Doherty John More other stuff
then cut by itself is useless. You could, however, use sed to collapse all the spaces into a single space and then pipe that to cut.
Barry Margolin