![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How printf handles empty variables | Skyybugg | Shell Programming and Scripting | 2 | 04-24-2008 01:32 PM |
| need help with User Defined Function | user_prady | Shell Programming and Scripting | 11 | 11-18-2007 08:51 PM |
| User defined service | markdrury | UNIX for Dummies Questions & Answers | 1 | 02-09-2006 01:08 AM |
| pre defined variables | sumsin | High Level Programming | 7 | 11-30-2005 12:13 PM |
| User defined signal 1 | nitesh_raj | AIX | 0 | 01-29-2005 02:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
awk printf for user defined variables
I am working on a SunFire 480 - uname -a gives:
SunOS bsmdb02 5.9 Generic_112233-08 sun4u sparc SUNW,Sun-Fire-480R I am tyring to sum up the total size of all the directories for each running database using awk: #!/usr/bin/ksh for Database in `ps -efl | grep "ora_pmon" | grep -v grep | awk '{printf("%s\n" ,$NF)}' | cut -f3 -d'_' | sort` do export Database # echo "$Database\c" find / -type d -name $Database -exec du -sk {} \; 2>/dev/null | awk '{ sum += $1 } END { printf("%10s\t%20s\n",$Database,sum) }' done #EOF I can get output in the format Database NNNNNNNN using the echo command, now commented out. If I try to use printf in the awk statement to format the output for both Database name and sum, the printf statement does not pick up the value of $Database (or Database for that matter). If I use the echo command for the Database name, the output format is difficult to control. How can I get the database name recognised in the printf statement? Thanks, Jabberwocky |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|