- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script
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
04-05-2004 07:28 PM
04-05-2004 07:28 PM
How can I eliminate the last character of a string in a shell script?
for example
pepitoA
to
pepito
Regards,
Mario.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 07:32 PM
04-05-2004 07:32 PM
Re: script
:s/oldtext/newtext/g
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 07:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 07:46 PM
04-05-2004 07:46 PM
Re: script
expr "pepitoA" : "\(.*\)."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 07:50 PM
04-05-2004 07:50 PM
Re: script
try this script:
STRING_A=pepitoA
STRING_B=`echo $STRING_A | awk '{printf("%s",substr($0,1,length($0)-1))}'`
echo $STRING_B
Be careful with the quotation.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 07:50 PM
04-05-2004 07:50 PM
Re: script
or use AWK.
echo pepitoA | awk '{ n=length($0)-1; print substr( $0, 0, n) }'
HTH,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 07:51 PM
04-05-2004 07:51 PM
Re: script
# echo PepitoA | sed -e 's/.$//'
:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 08:00 PM
04-05-2004 08:00 PM
Re: script
From shell man
${parameter%pattern}
${parameter%%pattern}
If the shell pattern matches the end of the
value of parameter, the value of parameter
with the matched part is deleted; otherwise
substitute the value of parameter. In the
former, the smallest matching pattern is
deleted; in the latter, the largest matching
pattern is deleted.
/home/steves >p=pepitoA
/home/steves >p=${p%?}
/home/steves >echo $p
pepito
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 08:08 PM
04-05-2004 08:08 PM
Re: script
I think your answer is the best one. I take note of it.
Congratulations.
Frank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 08:17 PM
04-05-2004 08:17 PM
Re: script
You can use
sed 's/oldtext/netext/g' filename >filename
cheers
Shyjith
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2004 09:21 PM
04-05-2004 09:21 PM
Re: script
The solusion of Steve is wonderful!
My solution :
printf "pepitoA" | perl -pe chop
(perl4 ok)