- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script help
Operating System - HP-UX
1753682
Members
5575
Online
108799
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
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
тАО02-11-2009 10:16 AM
тАО02-11-2009 10:16 AM
yea, im not a very good scripter, although I try very hard before I post for help, really.
I have a file that looks like this:
running "ls -l /etc/rc2.d/" on 172.xx.xxx.xxx:
-------------------------------------------------------------------------------
total 178
lrwxrwxrwx 1 root other 20 Jul 23 2007 K00.umask.sh -> /etc/init.d/umask.sh
lrwxrwxrwx 1 root other 26 Oct 2 2006 K02patchlinkagent -> /etc/init.d/patchlinkagent
-rwxr--r-- 1 root sys 344 Mar 20 2000 K06mipagent
-rwxr--r-- 1 root sys 861 Jan 5 2000 K07dmi
-rwxr--r-- 1 root sys 404 Jan 5 2000 K07snmpdx
-rwxr--r-- 6 root sys 621 Sep 1 21:53 K21dhcp
-rwxr--r-- 1 root sys 3080 Jan 5 2000 K28nfs.server
-rwxr-xr-x 1 root other 8543 Feb 25 2003 K50Tivoli_lcf1
lrwxrwxrwx 1 root other 20 Jul 23 2007 S00.umask.sh -> /etc/init.d/umask.sh
-rwxr--r-- 1 root sys 1881 Jan 5 2000 S01MOUNTFSYS
-rwxr--r-- 1 root sys 789 Apr 28 2004 S01VXFSLDLIC
-rwxr--r-- 1 root sys 2266 Dec 17 2002 S05RMTMPFILES
-rwxr--r-- 1 root sys 611 Jan 5 2000 S20sysetup
-rwxr--r-- 5 root sys 1517 Oct 28 21:49 S47asppp
-rwxr--r-- 5 root sys 1706 Oct 28 21:47 S47pppd
-r-xr-xr-x 1 root other 5813 Jan 10 2007 S68SEOS
-rwxr--r-- 1 root sys 12246 Dec 13 2004 S69inet
-rwxr--r-- 5 root sys 420 Oct 28 21:49 S71ldap.client
-rwxr--r-- 1 root sys 7278 Dec 19 2004 S72inetsvc
-rwxr--r-- 1 root sys 1144 May 19 2004 S73cachefs.daemon
-rwxr--r-- 1 root sys 911 Jan 5 2000 S74syslog
-rwxr--r-- 1 root sys 504 Jan 5 2000 S75cron
lrwxrwxrwx 1 root other 22 Jul 23 2007 S90tt_s02a111 -> /etc/init.d/tt_s02a111
-r-xr-xr-x 1 root sys 2333 Dec 5 2002 S94vxnm-vxnetd
-r-xr-xr-x 1 root sys 2309 Jun 26 2007 S95vxvm-recover
-r-x------ 1 root sys 2764 Dec 5 2002 S96vradmind
-r-x------ 1 root sys 2821 Dec 5 2002 S96vxrsyncd
-rwxr--r-- 1 root sys 493 Aug 7 2000 S98efcode
-r-xr-xr-x 1 root other 3692 Jan 10 2007 S99SEOS
lrwxrwxrwx 1 root other 18 Aug 1 2007 S99eccmad -> /etc/init.d/eccmad
-r-x--x--- 1 root other 6192 Mar 5 2005 _S68SEOS
-rwxr--r-- 2 root sys 715 Jan 20 2008 k16apache
and it repeats itself over and over for every IP we have.
how can I cut just the IP address and just the S9 programs that list under that IP?
I tried this but the IP's are all on top and the S9's are on the bottom.
cat rc2* | grep running |awk -F" " '{ print $6 }' && cat rc2* | awk -F" " '{ print $9 }' |grep S9 > fileout
I have a file that looks like this:
running "ls -l /etc/rc2.d/" on 172.xx.xxx.xxx:
-------------------------------------------------------------------------------
total 178
lrwxrwxrwx 1 root other 20 Jul 23 2007 K00.umask.sh -> /etc/init.d/umask.sh
lrwxrwxrwx 1 root other 26 Oct 2 2006 K02patchlinkagent -> /etc/init.d/patchlinkagent
-rwxr--r-- 1 root sys 344 Mar 20 2000 K06mipagent
-rwxr--r-- 1 root sys 861 Jan 5 2000 K07dmi
-rwxr--r-- 1 root sys 404 Jan 5 2000 K07snmpdx
-rwxr--r-- 6 root sys 621 Sep 1 21:53 K21dhcp
-rwxr--r-- 1 root sys 3080 Jan 5 2000 K28nfs.server
-rwxr-xr-x 1 root other 8543 Feb 25 2003 K50Tivoli_lcf1
lrwxrwxrwx 1 root other 20 Jul 23 2007 S00.umask.sh -> /etc/init.d/umask.sh
-rwxr--r-- 1 root sys 1881 Jan 5 2000 S01MOUNTFSYS
-rwxr--r-- 1 root sys 789 Apr 28 2004 S01VXFSLDLIC
-rwxr--r-- 1 root sys 2266 Dec 17 2002 S05RMTMPFILES
-rwxr--r-- 1 root sys 611 Jan 5 2000 S20sysetup
-rwxr--r-- 5 root sys 1517 Oct 28 21:49 S47asppp
-rwxr--r-- 5 root sys 1706 Oct 28 21:47 S47pppd
-r-xr-xr-x 1 root other 5813 Jan 10 2007 S68SEOS
-rwxr--r-- 1 root sys 12246 Dec 13 2004 S69inet
-rwxr--r-- 5 root sys 420 Oct 28 21:49 S71ldap.client
-rwxr--r-- 1 root sys 7278 Dec 19 2004 S72inetsvc
-rwxr--r-- 1 root sys 1144 May 19 2004 S73cachefs.daemon
-rwxr--r-- 1 root sys 911 Jan 5 2000 S74syslog
-rwxr--r-- 1 root sys 504 Jan 5 2000 S75cron
lrwxrwxrwx 1 root other 22 Jul 23 2007 S90tt_s02a111 -> /etc/init.d/tt_s02a111
-r-xr-xr-x 1 root sys 2333 Dec 5 2002 S94vxnm-vxnetd
-r-xr-xr-x 1 root sys 2309 Jun 26 2007 S95vxvm-recover
-r-x------ 1 root sys 2764 Dec 5 2002 S96vradmind
-r-x------ 1 root sys 2821 Dec 5 2002 S96vxrsyncd
-rwxr--r-- 1 root sys 493 Aug 7 2000 S98efcode
-r-xr-xr-x 1 root other 3692 Jan 10 2007 S99SEOS
lrwxrwxrwx 1 root other 18 Aug 1 2007 S99eccmad -> /etc/init.d/eccmad
-r-x--x--- 1 root other 6192 Mar 5 2005 _S68SEOS
-rwxr--r-- 2 root sys 715 Jan 20 2008 k16apache
and it repeats itself over and over for every IP we have.
how can I cut just the IP address and just the S9 programs that list under that IP?
I tried this but the IP's are all on top and the S9's are on the bottom.
cat rc2* | grep running |awk -F" " '{ print $6 }' && cat rc2* | awk -F" " '{ print $9 }' |grep S9 > fileout
UNIX IS GOOD
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 10:46 AM
тАО02-11-2009 10:46 AM
Solution
Bonsoir,
Don't know exactly how you want to present output. Here is what I can imagine in a first approach :
sed 's=^running "ls -l /etc/rc2.d/" on =FLAG_IP =' YourFile | sed 's=^.* S9=FLAG_S9 S9=' | grep "^FLAG_.. " | sed 's=^FLAG_IP =Found on node =' | sed 's=FLAG_S9 =- ='
From your example, copy/pasted in the file YourFile, it gives :
-----------------------------------------
Found on node 172.xx.xxx.xxx:
- S90tt_s02a111 -> /etc/init.d/tt_s02a111
- S94vxnm-vxnetd
- S95vxvm-recover
- S96vradmind
- S96vxrsyncd
- S98efcode
- S99SEOS
- S99eccmad -> /etc/init.d/eccmad
-----------------------------------------
Eric
Don't know exactly how you want to present output. Here is what I can imagine in a first approach :
sed 's=^running "ls -l /etc/rc2.d/" on =FLAG_IP =' YourFile | sed 's=^.* S9=FLAG_S9 S9=' | grep "^FLAG_.. " | sed 's=^FLAG_IP =Found on node =' | sed 's=FLAG_S9 =- ='
From your example, copy/pasted in the file YourFile, it gives :
-----------------------------------------
Found on node 172.xx.xxx.xxx:
- S90tt_s02a111 -> /etc/init.d/tt_s02a111
- S94vxnm-vxnetd
- S95vxvm-recover
- S96vradmind
- S96vxrsyncd
- S98efcode
- S99SEOS
- S99eccmad -> /etc/init.d/eccmad
-----------------------------------------
Eric
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 11:34 AM
тАО02-11-2009 11:34 AM
Re: script help
A simple
grep -e running -e S9 filename
should be sufficient. The grep command with multiple search strings keeps its matching findings in the order that it finds them in the file.
grep -e running -e S9 filename
should be sufficient. The grep command with multiple search strings keeps its matching findings in the order that it finds them in the file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-11-2009 11:40 AM
тАО02-11-2009 11:40 AM
Re: script help
No need for quite so many commands, you should be able to do it in one... something like one of these should do what you need.
sed -ne 's/^running .* on \(.*\):/\1/p; s/.* \(S9[^ ]*\).*/\1/p'
awk '/^running / { print $6; } / S9/ { print $9; }'
sed -ne 's/^running .* on \(.*\):/\1/p; s/.* \(S9[^ ]*\).*/\1/p'
awk '/^running / { print $6; } / S9/ { print $9; }'
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