- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: AWK output on HP-UX
Operating System - HP-UX
1752503
Members
5203
Online
108788
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
тАО11-26-2010 02:28 AM
тАО11-26-2010 02:28 AM
AWK output on HP-UX
Hello,
I have a problem with AWK on HP-UX. I have a script which asks for a specific date and then shows everything related to this date :
[code]
#!/bin/ksh
awk 'BEGIN{printf("Entrez la date : "); getline date < "-"}
$0 ~ date {f=1;print;next}
/^[0-9][0-9]\//{f=0}
f' Planning.csv > Planning.txt
[/code]
The problem is that with this script all the input file (Planning.csv) is redirected to the output file (Planning.txt) but not the specific data for the date entered.
Would you know why ?
Thanks for your help
I have a problem with AWK on HP-UX. I have a script which asks for a specific date and then shows everything related to this date :
[code]
#!/bin/ksh
awk 'BEGIN{printf("Entrez la date : "); getline date < "-"}
$0 ~ date {f=1;print;next}
/^[0-9][0-9]\//{f=0}
f' Planning.csv > Planning.txt
[/code]
The problem is that with this script all the input file (Planning.csv) is redirected to the output file (Planning.txt) but not the specific data for the date entered.
Would you know why ?
Thanks for your help
- Tags:
- awk
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2010 04:46 AM
тАО11-26-2010 04:46 AM
Re: AWK output on HP-UX
>BEGIN{printf("Entrez la date : "); getline date < "-"}
I would never do this prompt in awk. This is best left to the shell and then have the shell pass it to awk:
echo "Entrez la date: \c"
read DATE
awk -v date="$DATE" ...
>f' Planning.csv > Planning.txt
It would be clearer if you had an explicit print:
f { print }' Planning.csv > Planning.txt
>not the specific data for the date entered.
Add a print at the top to trace what's happening in your script.
I would never do this prompt in awk. This is best left to the shell and then have the shell pass it to awk:
echo "Entrez la date: \c"
read DATE
awk -v date="$DATE" ...
>f' Planning.csv > Planning.txt
It would be clearer if you had an explicit print:
f { print }' Planning.csv > Planning.txt
>not the specific data for the date entered.
Add a print at the top to trace what's happening in your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2010 08:51 AM
тАО11-26-2010 08:51 AM
Re: AWK output on HP-UX
Hi:
Why not use a simple 'grep' ?
# grep 11/26 Planning.csv > Planning.txt
If you only want to match at the beginning of a line:
# grep ^11/26 Planning.csv > Planning.txt
And if you want to skip lines that begin with a 2-digits perhaps to isolate lines with the date you want somewhere in the middle of the line:
# grep -v ^[0-9][0-9] Planning.csv | grep 11/26 > Planning.txt
Regards!
...JRF...
Why not use a simple 'grep' ?
# grep 11/26 Planning.csv > Planning.txt
If you only want to match at the beginning of a line:
# grep ^11/26 Planning.csv > Planning.txt
And if you want to skip lines that begin with a 2-digits perhaps to isolate lines with the date you want somewhere in the middle of the line:
# grep -v ^[0-9][0-9] Planning.csv | grep 11/26 > Planning.txt
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-26-2010 08:52 AM
тАО11-26-2010 08:52 AM
Re: AWK output on HP-UX
>> all the input file (Planning.csv) is redirected to the output file
Truly all, or perhaps everything after the first matching date?
Looks like the script sets a flag on date match anywhere in the line.
It clears that flag when it sees a line which start with number-number-slash
If the flag is set, then the line is printed.
What does the exact input look like?
Care to provide a sample?
1) depending on the input you can drop the ';print;next' as the line will be printed by the final 'f'.
2) looks like the flag-off condition is never triggered. Check and/or show your match logic.
hth,
Hein
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