- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk scripting help!
Operating System - HP-UX
1752762
Members
4880
Online
108789
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
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
тАО05-31-2002 11:10 AM
тАО05-31-2002 11:10 AM
awk scripting help!
Help ! I'm on a time limit and need to figure something out. I have a file, 3 columns, that I need to do some addition/subtraction on. Here is a sample:
1 1415767 532483
1 1978079 573705
2 233409 1714
2 259988 1865
What needs to happen, is for every row that has the same $1 (all the 1's, 2's,etc.), I need to take the $2 of the first row for that $1, and then either add or subtract the $2 of the next row down, based on which number is larger. After that is done for all the same $1's, then move to next $1 (ie. move from 1 to 2) and do the same for those. I'm really stumped with this one...
Thanks,
Sue
1 1415767 532483
1 1978079 573705
2 233409 1714
2 259988 1865
What needs to happen, is for every row that has the same $1 (all the 1's, 2's,etc.), I need to take the $2 of the first row for that $1, and then either add or subtract the $2 of the next row down, based on which number is larger. After that is done for all the same $1's, then move to next $1 (ie. move from 1 to 2) and do the same for those. I'm really stumped with this one...
Thanks,
Sue
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-31-2002 11:28 AM
тАО05-31-2002 11:28 AM
Re: awk scripting help!
This is really rather easy but I am going to do you a favor by not giving you the solution. You simply need to think in terms of associative arrays where $1 becomes the subscript of a set of pararllel arrays.
You also need to better define the problem: 1) What happens on the last member of a set of $1's? 2) After you add of subract using the secondf line, does this 'second' line become the new 'first' line or do you skip to the next line and start over?
Is the data already sorted on the first column? If not, can it be piped thru sort -n before awk?
I think when you answer these questions, your answer will pop out.
You also need to better define the problem: 1) What happens on the last member of a set of $1's? 2) After you add of subract using the secondf line, does this 'second' line become the new 'first' line or do you skip to the next line and start over?
Is the data already sorted on the first column? If not, can it be piped thru sort -n before awk?
I think when you answer these questions, your answer will pop out.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-01-2002 11:01 PM
тАО06-01-2002 11:01 PM
Re: awk scripting help!
Show us the desired output based on your 4-line sample. This will help me understand what (exactly) you are trying to do.
-tjh
-tjh
I learn something new everyday. (usually because I break something new everyday)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-03-2002 08:56 AM
тАО06-03-2002 08:56 AM
Re: awk scripting help!
This might help:
Great topic:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x96b70bce6f33d6118fff0090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x316efd3f91d3d5118ff40090279cd0f9,00.html
Great help in finding them:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x1e6f84534efbd5118ff40090279cd0f9,00.html
live free or die
harry
Great topic:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x96b70bce6f33d6118fff0090279cd0f9,00.html
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x316efd3f91d3d5118ff40090279cd0f9,00.html
Great help in finding them:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x1e6f84534efbd5118ff40090279cd0f9,00.html
live free or die
harry
Live Free or Die
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