- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Sed/Perl Question?
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
03-05-2010 03:37 PM
03-05-2010 03:37 PM
I have a command that gives me a list of clusters in the environment like this -
/cbo/bin/clusters
cboc10
cboc18
cboc22
cboc23
cboc24
cboc26
cboc27
cboc28
cboc29
cboc30
cboc32
cboc5
cbo
There is a small glitch in the way we represent cluster 1 (cbo). Ideally it should be presented as "cboc1" instead.
I want a way to get the numerics out of the list above but strugling due to c1 glitch since it doesnt have the numeric in the end.
I want to use the command in a for loop like this -
for i in `/cbo/bin/clusters|....` #want to get the numerics only here (10,18,22...1)
Thanks,
Allan.
Solved! Go to Solution.
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2010 04:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2010 04:10 PM
03-05-2010 04:10 PM
Re: Sed/Perl Question?
So the output I want is -
cboc10
.
.
.
.
.
qboc1
Thanks,
Allan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2010 04:13 PM
03-05-2010 04:13 PM
Re: Sed/Perl Question?
for i in $(< /cbo/bin/clusters); do
if [ "$i" = cbo ]; then
echo cboc1
else
echo $i
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2010 04:20 PM
03-05-2010 04:20 PM
Re: Sed/Perl Question?
If I understand you, correctly you want:
# sed -ne '/cboc[0-9]\{1,\}/p' file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2010 04:59 PM
03-05-2010 04:59 PM
Re: Sed/Perl Question?
OK, I think Dennis saw through what you were asking. In keeping with my 'sed' suggestions:
# sed -e 's/\([a-z]$\)/\11/' file
...which generalizes a bit to add a trailing "1" to those entries that end in [a-z].
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2010 05:23 PM
03-05-2010 05:23 PM
Re: Sed/Perl Question?
You probably want to add "c1" to the end then you can strip off the initial "cboc" and just get the numbers:
>want to get the numerics only here (10,18,22...1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2010 10:45 AM
03-08-2010 10:45 AM
Re: Sed/Perl Question?
Thanks, I went in with the one liner solution, though Dennis really made it easy.
Thanks,
Allan