HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: qustion:ask the usage of ${DISK##*/} in a she...
Operating System - HP-UX
1830930
Members
2316
Online
110017
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
Forums
Discussions
Discussions
Discussions
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
11-30-2007 11:11 PM
11-30-2007 11:11 PM
qustion:ask the usage of ${DISK##*/} in a shell??
qustion:ask the usage of ${DISK##*/} in a shell??
there is a shell:
echo "please input device name : \c"
read DISK
echo "${DISK##*/}"
after run ,I input /dev/rdsk/c2t6d0
the output is c2t6d0
I don't know the usage of ${DISK##*/},please help me explain it?? thank you!
there is a shell:
echo "please input device name : \c"
read DISK
echo "${DISK##*/}"
after run ,I input /dev/rdsk/c2t6d0
the output is c2t6d0
I don't know the usage of ${DISK##*/},please help me explain it?? thank you!
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2007 12:49 AM
12-01-2007 12:49 AM
Re: qustion:ask the usage of ${DISK##*/} in a shell??
${parameter##pattern}
If the shell pattern matches the beginning of
the value of parameter, the value of this
substitution is the value of the parameter
with the matched portion deleted; otherwise
the value of this parameter substituted. In
the former case, the smallest matching
pattern is deleted; in the latter case, the
largest matching pattern is deleted.
If the shell pattern matches the beginning of
the value of parameter, the value of this
substitution is the value of the parameter
with the matched portion deleted; otherwise
the value of this parameter substituted. In
the former case, the smallest matching
pattern is deleted; in the latter case, the
largest matching pattern is deleted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2007 07:06 PM
12-01-2007 07:06 PM
Re: qustion:ask the usage of ${DISK##*/} in a shell??
This is an example of using the (much more efficient) shell to replace an external command, in this case, the basename command. These are equivalent:
DISK=/dev/rdsk/c2t6d0
basename $DISK
echo "${DISK##*/}"
Both methods remove everything from the rightmost "/" to the beginning of the string. Similarly, there is a dirname command and an equivalent shell construct that will return only the directory portion:
DISK=/dev/rdsk/c2t6d0
dirname $DISK
echo "${DISK%/*}"
Bill Hassell, sysadmin
DISK=/dev/rdsk/c2t6d0
basename $DISK
echo "${DISK##*/}"
Both methods remove everything from the rightmost "/" to the beginning of the string. Similarly, there is a dirname command and an equivalent shell construct that will return only the directory portion:
DISK=/dev/rdsk/c2t6d0
dirname $DISK
echo "${DISK%/*}"
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2007 07:33 PM
12-01-2007 07:33 PM
Re: qustion:ask the usage of ${DISK##*/} in a shell??
thank you very muchï¼
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.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP