- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- shell issue: parameter substitution
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
тАО09-25-2007 08:03 PM
тАО09-25-2007 08:03 PM
I'm using the ${#} to check lexicographycally an IP address:
IP=192.112
echo "${IP%+([0-9].+([0-9])}"
19
Why does the pattern +([0-9]) remove just ONE digit from the first number while those same pattern removes all digits from the second number ?
Solved! Go to Solution.
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 08:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 08:32 PM
тАО09-25-2007 08:32 PM
Re: shell issue: parameter substitution
# IP=192.112
# echo "${IP%+([0-9].+([0-9])}"
192.112
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 09:01 PM
тАО09-25-2007 09:01 PM
Re: shell issue: parameter substitution
Tested as well in HP-UX 11.00 OS.
# uname -r
B.11.00
# echo $SHELL
/sbin/sh
# IP=192.112
# echo "${IP%+([0-9].+([0-9])}"
192.112
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 09:24 PM
тАО09-25-2007 09:24 PM
Re: shell issue: parameter substitution
Try this next one:
echo "${IP%+([0-9]).+([0-9])}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 09:35 PM
тАО09-25-2007 09:35 PM
Re: shell issue: parameter substitution
Can you clear what actually you want to print?
Regards,
Awadhesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 10:10 PM
тАО09-25-2007 10:10 PM
Re: shell issue: parameter substitution
# echo "${IP%+([0-9]).+([0-9])}"
19
# uname -r
B.11.11
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 10:42 PM
тАО09-25-2007 10:42 PM
Re: shell issue: parameter substitution
# IP=192.112
# AA=`echo $IP | awk -F. '{print $1}'`
# echo "${AA%+([0-9])}"
19
Thanks
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 10:44 PM
тАО09-25-2007 10:44 PM
Re: shell issue: parameter substitution
# IP=192.112
# BB=`echo $IP | awk -F. '{print $2}'`
# echo "${BB%+([0-9])}"
11
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2007 11:48 PM
тАО09-25-2007 11:48 PM
Re: shell issue: parameter substitution
# echo "${IP%\.*}"
192
# echo "${IP##[0-9]*\.}"
112
You should escape the dot which otherwise means any character.
Regards!
...JRF...