|
|||||
| | |||||
| sub-categories and articles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
delete_some_lines |
add | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
html_awk |
add | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| --->create new sub-category | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
addr2line.awk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add
#!/bin/awk -f # Copyright (C) 2000 Free Software Foundation # This file is part of libgcj. # This software is copyrighted work licensed under the terms of the # Libgcj License. Please consult the file "LIBGCJ_LICENSE" for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
awk.awk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| add
awk {print } translog.20020726125829.log | more mod ----------------- ===== ===== ===== C ===== ===== B ===== ===== C C ===== ===== ===== ===== C ===== ===== B B ===== ===== C C ===== ===== B B ===== ===== C C ===== ===== B B ===== ===== D D ===== ===== ===== ===== B ===== ===== C ===== ===== ===== ===== C ===== ===== B ===== ===== C ===== ===== B ===== ===== D ===== ===== ===== ===== B ===== ===== ===== ===== ===== ===== C ===== ===== B ===== ===== C ===== ===== ===== ===== C ===== awk {print } translog.20020726125829.log | sort | more ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ----------------- B B B B B B B B B B B B C C C C C C C C C C C C C C D D D mod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
awk.htm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
more guidelines
comparison.awkadd
| cat $ORATAB | while read LINE do case $LINE in \#*) ;; #comment-line in oratab *) dead.letter.txtadd
| From joe Fri Sep 6 14:32:23 2002 Return-Path: dos_2_unix.awkadd
| awk 'sub("$", "\r")' unixfile.txt > dosfile.txt function.awkadd
| # capitalize each word in a string function capitalize (input, result, words, n, i, w) { result = "" genbki.shfrom postgresql/src/backend/catalog
| #! /bin/sh #------------------------------------------------------------------------- # # genbki.sh-- # shell script which generates .bki files from specially formatted .h local_src.txtadd
| pwd /usr/share/awk ls_file.awkadd
| #!/bin/awk -f BEGIN { i=0; #unnecessary while ( "ls -la " | getline ) { if ( $5 < 100) { name[i] = $NF; size[i] = $5; passwdsadd
| here is all your text, joser print.awkadd
| #!/bin/awk -f BEGIN { object = ARGV[1]; ARGV[1] = ""; } print2.awkadd
| ls -lah | awk '{print $9 "\t\t" $5}' | sort rnaroznychmod 700 mail_send; mail_send some_file
| #!/bin/awk -f { cmd = "cat passwds | mail -s 'Your password for xyz' daz@jrfii.com"; system(cmd); } search_printadd
| if (/match/) {print;} search_print.awkadd
| #!/bin/awk -f # ifconfig | awk -f search_print.awk BEGIN {} { if (/inet addr/) {print;} short.awk ps -ef | awk '$4 > 60'
| ps -ef | awk '$4 > 60' touch_access.awkadd
| #!/bin/awk -f # run as ls -la | awk -f touch_access.awk BEGIN { i = 0 } { if ($1 ~ /^d.*/ amp;amp; $9 !~ /[\.|\.\.]/ ) { translog.20020726125829.logadd
| mod id time_now date_entered date_posted account num description memo action reconciled amount price date_reconciled ----------------- ===== START ===== END ===== START unix_2_dos.awkawk '{ sub("
$", ""); print }' dosfile.txt > unixfile.txt
| awk '{ sub("\r$", ""); print }' dosfile.txt > unixfile.txt unzip.awkadd
| #!/bin/awk -f BEGIN { i = 0 } { if ($1 ~ /.*\.zip/) { cmd = "mkdir -p ch"i "; cd ch"i "; unzip ../" $1 " ; cd .. "; validity.awkadd
| awk '{$2 = 3 print }' /etc/password x288.htmlFTN.AEN350add
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
x288.htmlFTN.AEN350.txt$ ls -lk /tmp -rw-r--r-- 1 patrice patrice 474 Mar 14 09:24 baz -rw-r--r-- 1 tester tester 44 Mar 14 09:24 foo drwxr-xr-x 2 patrice patrice 4096 Mar 14 09:24 foobar -rw------- 1 patrice patrice 1261 Mar 14 09:24 quotes |
If you want to calculate the size of all files owned by “patrice”, you can use awk. The following script does that for you:
$ ls -lk /tmp | awk '/^-/ && $3=="patrice" { total +=$5 } END { print total "k" }' |
How does it work? Every column of the ls command is stored in a variable. The variable is a dollar sign followed by the number of the column. The first line of the awk script matches all lines starting with a dash (this are files) and where the third column is equal to “patrice”. As the third column contains the owner name this gets all files owned by patrice. The block inside the curly braces gets executed for each match. This code sums up the size of this file to a total.