- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- shell script - how hard can it be
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
02-08-2007 11:10 PM
02-08-2007 11:10 PM
I simply want to use an if statement to see whether I should send the output of a command to my output file.
I'm using the following and only want to send the output to the file if the 1st 2 characters begin HP.
if [ $revision = "HP*" ];then
The above however doesn't work how do I do this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 11:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 11:22 PM
02-08-2007 11:22 PM
Re: shell script - how hard can it be
For instance shells such as Bash offer an expansion syntax which doesn't even require some external filter commands and yet let you extract a certain substring.
However, with HP posix shell you could do this
(but there are many other solutions conceivable)
(( $(expr "$revision" : ^HP) == 2 )) && echo do something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 11:29 PM
02-08-2007 11:29 PM
Re: shell script - how hard can it be
The correct terminology I was referring to when talking about Bash was "Parameter Substitution" and not "expansion".
But this is due to my English non-nativeness, I suppose.
And here's what I meant in Bash:
$ OS=$(uname -s)
$ [[ ${OS:0:2} = Li ]] && echo "we are running Linux"
we are running Linux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2007 11:38 PM
02-08-2007 11:38 PM
Re: shell script - how hard can it be
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2007 07:37 AM
02-09-2007 07:37 AM
Re: shell script - how hard can it be
if [[ "$revision" = HP* ]]; then
As in Ralph's case, you need [[ ]]. Don't quote the HP*.