- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- More help with awk
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
тАО04-28-2003 10:10 AM
тАО04-28-2003 10:10 AM
I have added local variables that get set with values and printed at the END. The single line output is intended for use with Oracle SQLLDR to save this info in a database table for later retrieval and analysis. Anyway, I am able to get all the local variables except 'srvr' to print on the single line. It seems to have something to do with the position of that variable on the line as it prints just fine when it is the last item. Here's the revised script:
awk -v ptnum=$portnum '($2 == "is" && $3 == "up,") {
print "Port# " ptnum " Status: " $3 " Protocol: " $7
pnum=ptnum
pstat=$3
protstat=$7
next}
($1 == "Description:") {
print " Server: " substr($0,16,30)
srvr=substr($0,16,30)
next}
($2 == "packets" && $3 == "input,") {
print " Pkt In: " $1 " Byte In: " $4
inp_pkt=$1
inp_byt=$4
next}
($2 == "input" && $3 == "errors,") {
print " IN Errs: " $1 " CRC: " $4
inp_err=$1
inp_crc=$4
next}
($2 == "packets" && $3 == "output,") {
print " Pkt Out: " $1 " Byte Out: " $4
out_pkt=$1
out_byt=$4
next}
($2 == "output" && $3 == "errors,") {
print " OUT Errs: " $1 " Collisions: " $4
out_err=$1
colls=$4
next}
END {
print srvr "," ptnum pstat "," protstat "," inp_pkt "," inp_byt "," inp_err "," inp_crc "," out_pkt "," out
_byt "," out_err "," colls "," }
' $pfile >> gpi.awk_out
That last 'print' statement is what I'm after.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2003 11:25 AM
тАО04-28-2003 11:25 AM
Re: More help with awk
What is a good way to strip ^M characters from a file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2003 11:39 AM
тАО04-28-2003 11:39 AM
Re: More help with awk
There are a couple of ways to strip the ^M characters out of the file. One way is to use the dos2ux command. Another way is to use sed like this:
sed 's/.$//'
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2003 11:39 AM
тАО04-28-2003 11:39 AM
Re: More help with awk
'sed' can correct this. You will need to press the CONTROL key, and while holding down the CONTROL key, press a lowercase "v". Continue to hold down the CONTROL key and press "M". This sequence generates a carriage return. This sequence is documented in 'ascii(5)'. When done properly, it will look like:
# echo "This is^M botched with CRs^M and needs to be fixed"|sed 's/^M//g'
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2003 11:43 AM