- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: how to capture last 2 digits/chars of variable
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
тАО05-11-2005 03:13 AM
тАО05-11-2005 03:13 AM
Thanks,
Theresa
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 03:27 AM
тАО05-11-2005 03:27 AM
Re: how to capture last 2 digits/chars of variable
It can capture from the end of the variable.
See the man page, its simple, available in the shell script.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 03:28 AM
тАО05-11-2005 03:28 AM
Re: how to capture last 2 digits/chars of variable
Im no good at this, I can only think of:
octant # echo $GAGA
sdjghkjdhfgkjhdf
octant # echo $GAGA|wc -m
17
octant # echo $GAGA|cut -c 15-17
df
Im sure some gurus out there will find the more subtle approach...
All the best
Victor
- Tags:
- cut
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 03:38 AM
тАО05-11-2005 03:38 AM
Re: how to capture last 2 digits/chars of variable
xterm
lt09:/home/merijn 111 > perl -le'($_=$ENV{TERM})=~s/^.*?(\d{1,2})$/$1/;print'
xterm
lt09:/home/merijn 112 > echo $WINDOWID
67108881
lt09:/home/merijn 113 > perl -le'($_=$ENV{WINDOWID})=~s/^.*?(\d{1,2})$/$1/;print'
81
lt09:/home/merijn 114 > echo $G_FILENAME_ENCODING
@locale,UTF-8,ISO-8859-1,CP1252
lt09:/home/merijn 115 > perl -le'($_=$ENV{G_FILENAME_ENCODING})=~s/^.*?(\d{1,2})$/$1/;print'
52
lt09:/home/merijn 116 >
Enjoy, Have FUN! H.Merijn
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 03:40 AM
тАО05-11-2005 03:40 AM
Re: how to capture last 2 digits/chars of variable
$ newvar=$(expr substr "$fish" $(expr length "$fish" - 1) 2)
$ echo $newvar
n?
- Tags:
- expr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 03:57 AM
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 04:14 AM
тАО05-11-2005 04:14 AM
Re: how to capture last 2 digits/chars of variable
var="$yourVariable"
x=${var%??}
last2char=${var#$x}
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 05:33 AM
тАО05-11-2005 05:33 AM
Re: how to capture last 2 digits/chars of variable
Thanks Again to everyone!
Theresa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 06:21 AM
тАО05-11-2005 06:21 AM
Re: how to capture last 2 digits/chars of variable
--8<---
In the parameter expansions shown previously, use of the colon in the
format results in a test for a parameter that is unset or null; omission
of the colon results in a test for a parameter that is only unset.
${#parameter} String Length. The length in characters of the
value of parameter.
-->8---
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-11-2005 06:22 AM
тАО05-11-2005 06:22 AM
Re: how to capture last 2 digits/chars of variable
--8<---
${parameter%word} Remove Smallest Suffix Pattern. The word is
expanded to produce a pattern. The parameter
expansion then results in parameter, with the
smallest portion of the suffix matched by the pat├в
tern deleted.
${parameter%%word} Remove Largest Suffix Pattern. The word is
expanded to produce a pattern. The parameter
expansion then results in parameter, with the
largest portion of the suffix matched by the pat├в
tern deleted.
${parameter#word} Remove Smallest Prefix Pattern. The word is
expanded to produce a pattern. The parameter
expansion then results in parameter, with the
smallest portion of the prefix matched by the pat├в
tern deleted.
${parameter##word} Remove Largest Prefix Pattern. The word is
expanded to produce a pattern. The parameter
expansion then results in parameter, with the
largest portion of the prefix matched by the pat├в
tern deleted.
-->8---
Enjoy, Have F