- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: matching a regexp
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
09-07-2006 05:08 AM
09-07-2006 05:08 AM
i want to auto install depots from many hosts, when i launch (for example):
swlist -v -s depot_path/file.depot |grep "^os_release "
the result is:
os_release ?.11.*
someone know how i could match $(uname -r) with "?.11.*" in a script ?
thanks
Cedrick Gaillard.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 05:30 AM
09-07-2006 05:30 AM
Re: matching a regexp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 05:42 AM
09-07-2006 05:42 AM
Re: matching a regexp
# uname -r | sed -n '/11\..*/p'
...returns non-enpty output if matched. Does that help?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 05:54 AM
09-07-2006 05:54 AM
Re: matching a regexp
count=`uname -r|grep -Ec ".[.]11[.].*"`
or if you just care for ".11." try this:
count=`uname -r|grep -c ".11."`
Then use $count in your if conditions... (shud be '1' if the OS is ?.11.*)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 06:08 AM
09-07-2006 06:08 AM
Re: matching a regexp
How about something like...
#!/usr/bin/sh
cd /depot_path
for f in $(ls -1 $PWD/*$(uname -r | cut -d. -f2-3)*)
do
swinstall -s ${f} \*
done
exit
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 06:45 AM
09-07-2006 06:45 AM
Re: matching a regexp
# echo $REV | awk '$0~/^.\.11\..*$/'
OR
# echo $REV | grep ".\.11\.*"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 08:57 AM
09-07-2006 08:57 AM
Re: matching a regexp
the result of 'swlist -v -s depot_path/file.depot |grep "^os_release "' could be:
?.11.* or ?.1[10].* or anithing else.
the result of 'uname -r' could be:
A.11.00 or B.11.23 or anything else.
i have tried to do something of simple:
echo 'B.11.11' |grep -E '?.11.*'
but that seems to work only on GNU grep ;(
hpux grep don't know the '?' char and i can't install GNU grep on all servers i want to auto-install the depots.
when i have started to write this auto-install script, i have renamed the original depots under the form:
$(uname -r).${PA_or_IA}$(getconf KERNEL_BITS).${softname}.depot
with that, i have create symlink for all versions supported by the depot but it's very dirty.
i did it temporary, until i finish to read the SD-UX documentation and the only way i found for something of clean is to extract the informations from the depot, so, i must deduct the name of the good package by interrogating all depots that matches the $softname var.
thanks.
Regards,
Cedrick Gaillard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 09:23 AM
09-07-2006 09:23 AM
Re: matching a regexp
try this...
# echo 'B.11.11' | grep "^[A-Z]\.11\.[0-9][0-9]$"
OR
# echo 'B.11.11' | grep "^[A-Z]\.11\.[0-9]\{2\}$"
hope it helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 10:40 AM
09-07-2006 10:40 AM
SolutionI assume you want to use the value of os_release to see if it matches your OS version. If so, given OS_PATTERN="?.11.*", you can use shell pattern matching inside of [[ ]]:
if [[ "$(uname -r)" = $OS_PATTERN ]]; then echo TRUE; else echo FALSE; fi
If you want to use grep/awk regular expressions, you can change the "." to "\." and then "?" to ".":
XX=$(echo "?.11.2*" | sed -e 's/\./\\./g' -e 's/?/./g')
- Tags:
- pattern
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 08:16 PM
09-07-2006 08:16 PM
Re: matching a regexp
$OS_PATTERN works very fine ;)
my problem is solved, big thanks all for your help.
PS:
"-a os_release" does not seems to work as expected beacause the result needs to be piped by grep in all manner:
$ swlist -v -s /depot/PHCO_27779.depot -a os_release
# Initializing...
# Contacting target "nr0u0169"...
#
# swlist Depot Table of Contents
#
# For depot: nr0u0169:/depot/PHCO_27779.depot
#
# Date: Fri Sep 8 10:12:40 2006
#
#
# No Bundle(s) on nr0u0169:/depot/PHCO_27779.depot
# Product(s):
#
PHCO_27779
vendor
product
os_release B.11.00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 08:41 PM
09-07-2006 08:41 PM
Re: matching a regexp
$ swlist -v -s /depot/PHCO_27779.depot -a os_release
When you use -a, you should remove the -v:
$ /usr/sbin/swlist -a os_release
# Bundle(s):
B3693AA ?.11.2*
B3901BA B.11.2[23]|B.11.31
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2006 10:14 PM
09-07-2006 10:14 PM
Re: matching a regexp
$ swlist -s /depot/PHCO_27779.depot -a os_release
# Initializing...
# Contacting target "nr0u0169"...
#
# Target: nr0u0169:/depot/PHCO_27779.depot
#
#
# No Bundle(s) on nr0u0169:/depot/PHCO_27779.depot
# Product(s):
#
PHCO_27779 B.11.00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 02:03 AM
09-08-2006 02:03 AM
Re: matching a regexp
this run on Hp-UX:
echo 'B.11.11' |grep -E '(.)*\.11\.(.)*'
(.)*=? in your example
\. to be sure to look for . (. it's a wildcard)
(.)*=* in your example
in general (.)* means any number of chars
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 02:09 AM
09-08-2006 02:09 AM
Re: matching a regexp
if you need more info:
man 5 regexp
Hth,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2006 03:08 AM
09-08-2006 03:08 AM
Re: matching a regexp
my problem is solved.
thanks for your input.