- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Awk output redirection?
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
Forums
Discussions
Discussions
Discussions
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
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
01-18-2002 02:20 AM
01-18-2002 02:20 AM
Awk output redirection?
I have a simple awk statement in my script which checks some stuff. If i run the statemtn from the command line i get exactly the output i want.
The problem is when i put it in the script and try to redirect the output to a file. It doesnt work.
awk '{if ( $2 == "Z" ) print $0}
How do i get the output to append to a logfile which i need to declare in a variable in the script or within the awk statement?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2002 02:24 AM
01-18-2002 02:24 AM
Re: Awk output redirection?
Hope I get you right.
Script:
====================================
LOGFILE=/var/adm/syslog/mylog
awk '{if ( $2 == "Z" ) print $0} >> $LOGFILE
====================================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2002 02:24 AM
01-18-2002 02:24 AM
Re: Awk output redirection?
eval " awk '{if ( $2 == "Z" ) print $0} " >> logfile
--
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2002 02:25 AM
01-18-2002 02:25 AM
Re: Awk output redirection?
awk '{if ( $2 == "Z" ) print $0} >> /tmp/logfile
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2002 02:42 AM
01-18-2002 02:42 AM
Re: Awk output redirection?
Btw, I notice that you missed out the ending single-quote in your awk command. Perhaps a typo?
awk '{if ( $2 == "Z" ) print $0}'
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2002 04:04 AM
01-18-2002 04:04 AM
Re: Awk output redirection?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2002 04:11 AM
01-18-2002 04:11 AM
Re: Awk output redirection?
LOGFILE=/export/.....
export LOGFILE
## redirection outside awk
awk ' $2 == "ZZ" { print $0 }' file >> $LOGFILE
## redirection inside awk
awk ' $2 == "Z" { print $0 >> log}' log=$LOGFILE file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2002 05:01 AM
01-18-2002 05:01 AM
Re: Awk output redirection?
Explains why the relative worked and the absolute path didnt. the files were one dir. up :)
But thx alot anyway!!