- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script 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
тАО06-28-2005 05:42 AM
тАО06-28-2005 05:42 AM
Script Help
File contents:
Register 6
CASH 100.00
CHECK 50.00
Register 6
.....other stuff
Register 7
CASH 2000.00
CHECK 10.00
Register 7
.....other stuff, etc.
I need my output to be
Register 6
CASH 100.00
CHECK 50.00
Register 7
CASH 2000.00
CHECK 10.00
Any advice on the best utility to use?
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 05:48 AM
тАО06-28-2005 05:48 AM
Re: Script Help
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 05:53 AM
тАО06-28-2005 05:53 AM
Re: Script Help
Create a script in a file called useme.awk :
/^Register/ {dareg=$0}
/CASH/ {dacash=$0}
/CHECK/ {print dareg; print dacash; print $0}
Run the script like this:
awk -f useme.awk < inputfile > outputfile
Best regards,
Kent M. Ostby
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 08:30 AM
тАО06-28-2005 08:30 AM
Re: Script Help
Are you trying to display the sum of the amounts (cash or check) at the different registers? I'm not sure from your posting; could you clarify.
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 09:13 AM
тАО06-28-2005 09:13 AM
Re: Script Help
and the cash and check amounts under the register number. The register numbers are listed twice in the file as well as some other garbage that i don't need. So I want the output to be something like
Register 6
CASH 100.00
CHECK 50.00
Register 7
CASH 2000.00
CHECK 10.00
With the register number and then the corresponding cash and check amounts.
Thanks for any help. I tried the other two suggestions. Couldn't get the grep to work and the awk script did not print register numbers but only amounts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 11:43 AM
тАО06-28-2005 11:43 AM
Re: Script Help
awk '/^Register/{dareg=$0}/CASH/{dacash=$0}/CHECK/{print dareg;print dacash;print $0}' < file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2005 07:00 PM
тАО06-28-2005 07:00 PM
Re: Script Help
# awk '{ if ( $1 == "Register") { ln1=$0;getline ln2; split(ln2,a," ");if (a[1]=="CASH") { getline ln3; split(ln3,b," ");if (b[1]=="CHECK") { print ln1"\n"ln2"\n"ln3}}} print "\n";}'
hth.