|
Number lines in a file AWK
|
|
01-11-2010, 09:13 AM
(This post was last modified: 01-11-2010 09:17 AM by codecaine.)
Post: #1
|
|||
|
|||
|
Number lines in a file AWK
lineNumber is global variable because its in the begin section. For each line lineNumber is incremented by 1. then I just made a simple printf statement printing the line count and the entire line. If you save the filename as myscript you can execute the program like this. Remember you must my shell scripts executable chmod 755 myscript
Code: #!/bin/bashOf course you can use cat in BASH to do the exact same thing. Each line is tabbed at the beginning though. Code: cat -n /etc/passwd |
|||
|
01-11-2010, 08:25 PM
Post: #2
|
|||
|
|||
|
RE: Number lines in a file AWK
This is almost the same as in C++.
It is interesting how it outputs it in a file ! "I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein |
|||
|
« Next Oldest | Next Newest »
|







