- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: 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 11:56 PM
тАО09-25-2007 11:56 PM
Re: shell issue: parameter substitution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2007 04:00 AM
тАО09-26-2007 04:00 AM
Re: shell issue: parameter substitution
In the above expression the shell is doing what it has been asked of; delete the shortest matching pattern as a single percent sign was specified. On the other hand if the expression was:
# echo "${IP%%+([0-9]).+([0-9])}"
...then it deletes the longest matching pattern which is the entire string as a double percent sign was specified. See the sh-posix(1) man page for details.
~cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2007 09:38 PM
тАО09-26-2007 09:38 PM
Re: shell issue: parameter substitution
Actually no. This is a file matching pattern not a regular expression. In a pattern you have "*" and "?".
- Tags:
- regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2007 10:32 PM
тАО09-26-2007 10:32 PM
Re: shell issue: parameter substitution
I'm trying to check lexicographically an IP address.
I'm very distrustful :-( -- I don't trust external commands as grep or awk, so I prefer to use shell internal tricks
I know the difference of ${%} and ${%%} but in my example pattern
echo "${IP%+([0-9]).+([0-9])}"
I cannot understand why the same sub-pattern
+([0-9])
matches the full last byte (112) BUT only one digit from the first byte (192).
Does the 'shortest length' behaviour of ${%} apply only to the sub-pattern following the character '%' ?
Thanx in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-26-2007 10:51 PM
тАО09-26-2007 10:51 PM
Re: shell issue: parameter substitution
>Does the 'shortest length' behaviour of ${%} apply only to the sub-pattern following the character '%'?
As Sandman said, it applies to everything. Since the last pattern must match ALL of 112 to match the ".", it does. But to match 192, it only has to match the shortest.
I would suggest you trust in the grep and regular expressions. grep/awk aren't the darkside ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2007 02:45 AM
тАО09-27-2007 02:45 AM
Re: shell issue: parameter substitution
>following the character '%' ?
Yes it does...and the difference can be seen in the following constructs...
# IP=192.112
# echo "${IP%+([0-9])}"
192.11
# echo "${IP%%+([0-9])}"
192.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-27-2007 09:03 PM
тАО09-27-2007 09:03 PM
Re: shell issue: parameter substitution
- « Previous
-
- 1
- 2
- Next »