- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- PS1 Confusion
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
тАО03-13-2009 01:50 PM
тАО03-13-2009 01:50 PM
export PS1="$accountName "'${PWD##*($HOME|$HOME/)}$ '
The prompt looks like this:
[aea11-un] data$
The account name is "aea11-un"
The PWD is set to /ifastest/bsi/data
The $HOME is set to /ifastest/bsi
I'm confused about the two ## and the *. What do they do?
And the $HOME|$HOME/ ? Confused on what it does.
Looks like it is stripping off the 1st two nodes of the pwd command.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 02:02 PM
тАО03-13-2009 02:02 PM
Solution> I'm confused about the two ## and the *. What do they do?
Just what you deduced. The '${parameter##pattern}' is described in the 'sh-posix' manpages. If the 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.
See the Pattern Substitution section of:
http://www.docs.hp.com/en/B2355-60105/sh-posix.1.html
> And the $HOME|$HOME/ ? Confused on what it does.
This says to match either the value of '$HOME' or ('|') the value of '$HOME/' (that is with a forward slash following it.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 02:11 PM
тАО03-13-2009 02:11 PM
Re: PS1 Confusion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-13-2009 08:27 PM
тАО03-13-2009 08:27 PM
Re: PS1 Confusion
Your the best!
And thanks for the link to the HP docs section on pattern substitution. That paper has cleared up a lot of other questions I had.
This forum is priceless!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2009 07:38 PM
тАО03-14-2009 07:38 PM
Re: PS1 Confusion
export PS1="$accountName "'${PWD##${PWD%/*/*}/} $'
In this example, the lowest two directories are shown. So if you change to /usr/local/bin, the prompt will be:
[aea11-un] local/bin $
Knowing that you are in the bin directory is not enough. The current PWD and the parent provide most of the details without showing the entire $PWD.
Further details: The double quotes around "$accountName " will be set permanently with PS1= assignment but the single quotes (apostrophes) will be evaluated every time the PS1 variable is displayed.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-14-2009 07:58 PM
тАО03-14-2009 07:58 PM
Re: PS1 Confusion
Thank you for the update. Never knew the PS1 prompt had sooo many options. I'll try your recommendation.