- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script command
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
01-05-2001 07:52 AM
01-05-2001 07:52 AM
(5%).
I need to strip the parens, the percent and the period from the output. The number may be a one, two or three digit number. Does anyone know how to remove the other characters? Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 07:58 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 07:59 AM
01-05-2001 07:59 AM
Re: Script command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 08:04 AM
01-05-2001 08:04 AM
Re: Script command
value=${value%%%*}
value=${value##\(*}
print $value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 08:12 AM
01-05-2001 08:12 AM
Re: Script command
Here is a sed construct using regular expressions. It's a bit more general as it suppresses all non-digit characters:
echo $number | sed 's/[^[:digit:]]//g'
see man 5 regexp for details
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 08:13 AM
01-05-2001 08:13 AM
Re: Script command
value=${value##\(*}
should have been:
value=${value##*\(}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 09:41 AM
01-05-2001 09:41 AM
Re: Script command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 09:42 AM
01-05-2001 09:42 AM
Re: Script command
Best bet is to use sed to strip the unwanted characters. Inside your script you can use 3 lines of sed to get rid of the known characters you do not want.
input="(5%)"
step1=`echo ${input} | sed -e '1,$s/(//g'`
step2=`echo ${step1} | sed -e '1,$s/)//g'`
output=`echo ${step2} | sed -e '1,$s/%//g'`
echo $output
5
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 10:24 AM
01-05-2001 10:24 AM
Re: Script command
sorry, the above didn't work for you. I guess I should have specified the shell.
it does work for ksh, for the posix shell you'll have to backslash the 3rd % character and if ksh was newer the 88 version you'd could have just done:
value=${value//[![:digit:]]/}
print $value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2001 11:15 AM
01-05-2001 11:15 AM
Re: Script command
thanks for clarifying. It does work in Korn Shell. I'll have to do more with korn one day......POSIX is global, so I use it all the time. Scripts in SCO, Linux, SunOS, HP-UX, AIX, and IRIX all work using the posix standard shell commands.........
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2001 11:24 PM
01-07-2001 11:24 PM
Re: Script command
| awk -F\( '{print $2}' | awk -F% '{print $1}'
or with sed (which BTW can take several "edits" as arguments, so no need to divide):
| sed -e 's:(::' -e 's:%.$::'