- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: data processing
Operating System - HP-UX
1753772
Members
5255
Online
108799
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО09-14-2009 04:13 AM
тАО09-14-2009 04:13 AM
Hi Guyz,
I have a file containing three columns
1 10 A
11 20 B
21 30 C.
I was about to write a script that reads an input number then produce result based on the file if it is between the first two columns.
Example if i inputed 5. It is between 1 and 10 (based on the file) and will give me an output of A (which is the assigned letter on the third column).
Can someone help me how to do this? that after reading a number. it will search each line in the file to which the number is in between those ranges then register the output of assigned letter from the 3rd column.
Thanks in advance
Cheers
I have a file containing three columns
1 10 A
11 20 B
21 30 C.
I was about to write a script that reads an input number then produce result based on the file if it is between the first two columns.
Example if i inputed 5. It is between 1 and 10 (based on the file) and will give me an output of A (which is the assigned letter on the third column).
Can someone help me how to do this? that after reading a number. it will search each line in the file to which the number is in between those ranges then register the output of assigned letter from the 3rd column.
Thanks in advance
Cheers
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2009 04:25 AM
тАО09-14-2009 04:25 AM
Solution
Here is a sample solution.
The table file is call x.txt and read as main data.
The target variable is passed as a variable on the command line.
$ awk -v target=6 'target > $1 && target < $2 {print $3; x++} END {if (!x) print "NOT IN RANGE"}' x.txt
If the targets also come from a file, the you may want to read the table in an AWK or PERL 'BEGIN' section first and then read the values and process in the main block.
hth,
Hein.
The table file is call x.txt and read as main data.
The target variable is passed as a variable on the command line.
$ awk -v target=6 'target > $1 && target < $2 {print $3; x++} END {if (!x) print "NOT IN RANGE"}' x.txt
If the targets also come from a file, the you may want to read the table in an AWK or PERL 'BEGIN' section first and then read the values and process in the main block.
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2009 04:34 AM
тАО09-14-2009 04:34 AM
Re: data processing
Thanks so much. This is exactly what resolves my case. cheers
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP