Sponsored Content
Full Discussion: need help du -sk
Top Forums UNIX for Dummies Questions & Answers need help du -sk Post 302097266 by arunkumar_mca on Wednesday 22nd of November 2006 11:58:57 PM
Old 11-23-2006
Quote:
Originally Posted by grial
Sure!
Code:
... awk '{count+=$1; print}END {print "Total:  ",count,"kb"}'

I'm not an awk expert but here we go!
"count" is where the size is going to be contained.
In the first {}, for each line (result of du), count will increment by adding the first field value, represented by $1 (by default fields are separated by spaces and/or tabs). In this case, the first field is the size of the folder. And print the whole line.
Finally, in the second {}, the result is shown.
Regards.

Grial thanks for your explanation and very great of you .. Please let me know why we are using print here "{count+=$1; print}" . please let me know the use of print here if we didnt use print here is it right ?? .Let me know ,also with that i am new to AWK...

Thanks in advance,
Arun kumar
 
RECSEL(1)							   User Commands							 RECSEL(1)

NAME
recsel - print records from a recfile SYNOPSIS
recsel [OPTION]... [-t TYPE] [-n INDEXES | -e RECORD_EXPR | -q EXPR | -m NUM] [-c | (-p|-P) FIELD_EXPR] [FILE]... DESCRIPTION
Select and print rec data. -d, --include-descriptors print record descriptors along with the matched records. -C, --collapse do not section the result in records with newlines. -S, --sort=FIELD sort the output by the specified field. -U, --uniq remove duplicated fields in the output records. -s, --password=STR decrypt confidential fields with the given password. --help print a help message and exit. --version show version and exit. Record selection options: -i, --case-insensitive make strings case-insensitive in selection expressions. -t, --type=TYPE operate on records of the specified type only. -e, --expression=EXPR selection expression. -q, --quick=STR select records with fields containing a string. -n, --number=NUM,... select specific records by position, with ranges. -R, --random=NUM select a given number of random records. Output options: -p, --print=FIELDS comma-separated list of fields to print for each matching record. -P, --print-values=FIELDS as -p, but print only the values of the selected fields. -R, --print-row=FIELDS as -P, but separate the values with spaces instead of newlines. -c, --count print a count of the matching records instead of the records themselves. Special options: --print-sexps print the data in sexps instead of rec format. AUTHOR
Written by Jose E. Marchesi. REPORTING BUGS
Report bugs to: bug-recutils@gnu.org GNU recutils home page: <http://www.gnu.org/software/recutils/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2010, 2011, 2012 Jose E. Marchesi. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for recsel is maintained as a Texinfo manual. If the info and recsel programs are properly installed at your site, the command info recsel should give you access to the complete manual. recsel 1.4.93 January 2012 RECSEL(1)
All times are GMT -4. The time now is 10:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy