English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

is there a command simmilar to awk that instead of printing colums, as awk does, prints rows?

2007-08-14 06:17:16 · 5 answers · asked by toodles_1399 1 in Computers & Internet Programming & Design

that just displays what i want it to...i have a .txt file that i want to print say...line 5 of...

2007-08-14 06:29:58 · update #1

5 answers

"head" and "tail" will do that.

For example, if I want to print the fourth line of a file, I can do this:

head -4 myfile.txt | tail -1

"head -4" prints the first four lines, tail -1 prints the last line of those four.

2007-08-14 06:31:50 · answer #1 · answered by McFate 7 · 0 0

"awk" can do a lot more than print columns. For example,
you can select specific lines by looking at the NR variable.
To print out lines 5 through 10 of some file:

     awk '{ if (NR>=5 && NR<=10) print $0; }' < somefile

"awk" has the advantage of allowing you to write
arbitrarily complex selection logic.

For simpler "row" selection of a file, you might
want to use "head" and/or "tail".

For example, to print the first 5 rows of a file:

head -5 somefile

To print the last 5 rows of a file:

tail -5 somefile

To print lines 6 through 10 of a file, use "head" to
select the first 10, and then apply "tail" to *that*
output to just take the last 5 of them:

head -10 somefile | tail -5

2007-08-14 06:33:35 · answer #2 · answered by morgan 7 · 0 0

cat Copies the report to STDOUT. there are a sort of instructions that pass on your device's print queue. It relies upon at certainly one of those print queue amenities you had put in. attempt enscript. additionally attempt lpstat -a and lpstat -l in case you have put in CUPS.

2016-10-15 07:42:58 · answer #3 · answered by Anonymous · 0 0

echo["print statements"]

2007-08-14 06:29:00 · answer #4 · answered by satya e 2 · 0 0

'cat mytextfile.txt -n'

2007-08-14 07:00:09 · answer #5 · answered by Anonymous · 0 0

fedest.com, questions and answers