- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Comparing columns in a file help
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
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
тАО05-04-2009 08:20 AM
тАО05-04-2009 08:20 AM
file1:
10.994 14.514
13.506 16.587
16.156 15.597
14.008 13.609
12.617 14.532
I need to compare the 2 columns and determine that if column 2's value is greater than column 1's value by double or more I want to know about it. basically just print the row that meets that above standards. Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2009 08:47 AM
тАО05-04-2009 08:47 AM
Re: Comparing columns in a file help
Or, are you wanting all lines where column 2 is simply greater than column 1?
Your data, and your description, do not go together, at all.
Now, presuming that your description is what you want, the following awk command should work for you:
awk '{a=$1*2;if(a>=$2){print $0}}' < input_file
This will display back to stdout all lines where the value in column 2 is twice or more the value in column 1.
HP-Server-Literate since 1979
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2009 08:51 AM
тАО05-04-2009 08:51 AM
Re: Comparing columns in a file help
Thanks, the file was just an example, there are hundreds and hundreds of lines in the file and happen to grab some that dont work. Thanks again for the idea. I'll test it out and see if its what I need, i appreciate your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2009 09:05 AM
тАО05-04-2009 09:05 AM
Re: Comparing columns in a file help
1.242 4.363 (Works here)
1.268 8.955 (Works here)
1.346 0.888 (Not here)
1.195 0.992 (Not here)
Thanks again for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2009 09:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-04-2009 09:33 AM
тАО05-04-2009 09:33 AM
Re: Comparing columns in a file help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-05-2009 02:04 AM
тАО05-05-2009 02:04 AM
Re: Comparing columns in a file help
# while read col1 col2; do if [ $(echo $col1*2000 | bc ) -lt $(echo $col2*1000 | bc ) ];then echo $col1 $col2;fi;done < inputfile
Unix operates with beer.
- Tags:
- while loop