- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How print output of awk into specific file based o...
Operating System - Linux
1820553
Members
2468
Online
109626
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
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
Go to solution
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-16-2006 07:50 PM
тАО11-16-2006 07:50 PM
Hi all,
usnig this part of code
cat 942prm_200611* | tr ' | ' ' ' > 942sve.txt
awk ' { if(( $10=="30001") && (($22=="34") || ($22=="128") || ($21=="31"))) print $10 "\t" $22 }' 942sve.txt > jacause.txt
awk ' { if(( $10=="30350") && (($22=="31") || ($22=="128") || ($22=="16"))) print $10 "\t" $22 }' 942sve.txt >> jacause.txt
awk ' { if(( $10=="50111") && (($22=="34") || ($22=="128"))) print $10 "\t" $22 }' 942sve.txt >> jacause.txt
I got output like bellow ....
30001 128
30001 128
30001 128
30350 16
30350 16
30350 16
30350 16
30350 31
30350 128
30350 128
30350 31
30350 128
30350 31
30350 16
30350 128
30350 31
30350 31
first column means telephne number and second column menas specific cause for that number. Now I need to implement additional script ( or inside this one ) that will make possible to for example number 30350 select all causes to different files. I need to make output like
in file 30350_128.txt should be
30350 128
30350 128
30350 128
in file 30350_31.txt
30350 31
30350 31
in file 30350_16.txt
30350 16
30350 16
30350 16
30350 16
For number 30001 I need make the same
for example 30001_128.txt
30001 128
30001 128
30001 128
( there is no other causes for this number, just this one )
and for every differnt number in column one write data for specific cause in column 2 into differen file like in example above.
I am hoping that someone know how to do this and have time to write, or just send me an hint how to do this... and help me.
I must do it in awk, no other program languages.
Thank you in advance
usnig this part of code
cat 942prm_200611* | tr ' | ' ' ' > 942sve.txt
awk ' { if(( $10=="30001") && (($22=="34") || ($22=="128") || ($21=="31"))) print $10 "\t" $22 }' 942sve.txt > jacause.txt
awk ' { if(( $10=="30350") && (($22=="31") || ($22=="128") || ($22=="16"))) print $10 "\t" $22 }' 942sve.txt >> jacause.txt
awk ' { if(( $10=="50111") && (($22=="34") || ($22=="128"))) print $10 "\t" $22 }' 942sve.txt >> jacause.txt
I got output like bellow ....
30001 128
30001 128
30001 128
30350 16
30350 16
30350 16
30350 16
30350 31
30350 128
30350 128
30350 31
30350 128
30350 31
30350 16
30350 128
30350 31
30350 31
first column means telephne number and second column menas specific cause for that number. Now I need to implement additional script ( or inside this one ) that will make possible to for example number 30350 select all causes to different files. I need to make output like
in file 30350_128.txt should be
30350 128
30350 128
30350 128
in file 30350_31.txt
30350 31
30350 31
in file 30350_16.txt
30350 16
30350 16
30350 16
30350 16
For number 30001 I need make the same
for example 30001_128.txt
30001 128
30001 128
30001 128
( there is no other causes for this number, just this one )
and for every differnt number in column one write data for specific cause in column 2 into differen file like in example above.
I am hoping that someone know how to do this and have time to write, or just send me an hint how to do this... and help me.
I must do it in awk, no other program languages.
Thank you in advance
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2006 11:24 PM
тАО11-16-2006 11:24 PM
Re: How print output of awk into specific file based on column parameter?
Hi,
you may want to expand on Hein's answer in
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=856411
Another helpful util could also be:
uniq -c to count the unique entries for each key (number + cause)
you may want to expand on Hein's answer in
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=856411
Another helpful util could also be:
uniq -c to count the unique entries for each key (number + cause)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2006 09:55 PM
тАО11-19-2006 09:55 PM
Solution
Hello
awk '{ u[$1 "_" $2 ] ++ }
END {
for (x in u )
{ printf "%d messages",u[x] >("f" x ".txt") }
}' jacause.txt
to count
or
awk '{printf $0 > $1 "_" $2 ".txt"}' jacause.txt to answer your question.
Jean-Yves Picard
awk '{ u[$1 "_" $2 ] ++ }
END {
for (x in u )
{ printf "%d messages",u[x] >("f" x ".txt") }
}' jacause.txt
to count
or
awk '{printf $0 > $1 "_" $2 ".txt"}' jacause.txt to answer your question.
Jean-Yves Picard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-19-2006 11:16 PM
тАО11-19-2006 11:16 PM
Re: How print output of awk into specific file based on column parameter?
Thank you, with your help I solved this :)
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.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP