|
Awk script format example
|
|
01-11-2010, 08:48 AM
(This post was last modified: 01-11-2010 09:01 AM by codecaine.)
Post: #1
|
|||
|
|||
|
Awk script format example
I saved this file as test.awk. Then I did chmod 555 test.awk so anybody can read and execute the script. Then ./test.awk /etc/passwd to test it on the password file.
#!/bin/bash #search for lines that have sh in it awk /sh/' #This begin section allows you to initialize and set global varibles in awk BEGIN{ #don't have any code to put in here } #this is the main body if you want to do a operation on each line in the file { #don't have any code to put in here } #this section only execute at the end of the script of awk END{ print "Script finished" } ' "$1" #this will get the first argument from the command. I directed it to /etc/passwd. Notice I put quotes around it incase there is spaces in the file name Here is the actually code because you can't put # inside the ' ' that is syntax error. Everything has to before the single quotes. Code: #!/bin/bash |
|||
|
01-11-2010, 08:18 PM
Post: #2
|
|||
|
|||
|
RE: Awk script format example
Very good !
There's a fine line between genius and insanity. I have erased this line. Oscar Levant There's a fine line between an administrator and black hat hacker. I have erased this line. Dr DEBCOL |
|||
|
« Next Oldest | Next Newest »
|





