- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: ksh variables inside awk script inside ksh scr...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2005 08:34 AM
тАО06-14-2005 08:34 AM
SIZES= 3 4325 8632 160000
for Size in $SIZES
do
awk '
$NF == $Size { Count = Count + 1
Total = Total + $NF }
END { TotGB = Total / 1000
printf ("%8d %6d %6d GB \n", $NF, Count, TotGB) }
' $SYMDEV.1
done > $SYMDEV.2
I can't get the $Size inside the awk to substitute into a 3, 4315, etc.
How do i do that?
Solved! Go to Solution.
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2005 08:54 AM
тАО06-14-2005 08:54 AM
Re: ksh variables inside awk script inside ksh script ?
Hope this helps...
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2005 08:54 AM
тАО06-14-2005 08:54 AM
Re: ksh variables inside awk script inside ksh script ?
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2005 08:59 AM
тАО06-14-2005 08:59 AM
Solutionawk -v Size=${Size} '$NF == Size ....'
The -v Size=${SIZE} create an awk variable 'Size' (not $Size inside awk) and gives it the value of the shell variable ${Size}.
I've intentionally not done everything for you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2005 11:54 AM
тАО06-14-2005 11:54 AM
Re: ksh variables inside awk script inside ksh script ?
You need to replace the single ticks with double quotes in your awk script otherwise variable expansion will not occur. Also change the double quotes of your printf statement to single quotes so that awk can correctly parse your statements.
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2005 04:57 PM
тАО06-14-2005 04:57 PM
Re: ksh variables inside awk script inside ksh script ?
Try this with -v option
SIZES= 3 4325 8632 160000
for Size in $SIZES
do
awk -v NF=$Size '
{ Count = Count + 1
Total = Total + $NF }
END { TotGB = Total / 1000
printf ("%8d %6d %6d GB \n", $NF, Count, TotGB) }
' $SYMDEV.1
done > $SYMDEV.2
Should work
Cheers !!!
eknath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-15-2005 03:26 AM
тАО06-15-2005 03:26 AM
Re: ksh variables inside awk script inside ksh script ?
$NF == Size {Count = Count +1 ...