- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: AWK again...
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
Forums
Discussions
Discussions
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
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
05-22-2002 10:17 PM
05-22-2002 10:17 PM
I have the text file in the format below:
#cat file1.txt
23400 joe_bloggs
56690 sunny_lee
56789 terrence_lam
The left most column represent the disk-usage by the the users on the right column, i.e. their home directory disk usage.
I would like to display only users >40MB i.e 40000k of space into a different file. I did the following:
#!/bin/sh
for i in `cat file1`
do
if($1 > 40000)
echo $1 $2 >> list.txt
done
It produced the following error:
Syntax error at line 3: ')' is not expected
I had also tried the one below on the console:
#cat file1 | awk `{if($1>40000)}{print $1 $2}`
and it produced the same kind of error.
Can someone help me out in this?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2002 10:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2002 11:16 PM
05-22-2002 11:16 PM
Re: AWK again...
you may wish to sort this into ascending order too.
cat file1 | awk '{ if ($1 > 40000) print $2 }' | sort +n +0
cheers
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2002 12:04 AM
05-23-2002 12:04 AM
Re: AWK again...
awk '$1>40000{ print }' filename | sort +0n
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2002 12:17 AM
05-23-2002 12:17 AM
Re: AWK again...
I tried the following which you suggested:
awk '$1>40000{ print }' filename | sort +0n
Unfortunately, it produced as error:
Error context is
$1 >>>> 40000{print}' <<<
I'm not sure if it I did the right way...
Could you clarify?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2002 12:33 AM
05-23-2002 12:33 AM
Re: AWK again...
an over sight on my part this should have been
cat file1 | awk '{ if ($1 > 40000) print $1 " " $2 }' | sort +n +0
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2002 12:33 AM
05-23-2002 12:33 AM
Re: AWK again...
I think you forgot the blanks inside the { } :
awk '$1>40000{ print }' file1 | sort +0n
You also need to replace "filename" by your filename, "file1".
Regards,
Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2002 12:57 AM
05-23-2002 12:57 AM
Re: AWK again...
Tom's answer is the right one and best one
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2002 01:16 AM
05-23-2002 01:16 AM
Re: AWK again...
thanks very much - solutions were simple yet helpful.
Tom,
yes, I forgot the space between { print }!!
Thanks all