- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: String manipulation
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
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
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
тАО11-20-2003 11:10 AM
тАО11-20-2003 11:10 AM
String manipulation
I have a string variable s="manipulate"
I want to extract from pos 2 to 5 . I should get a string "anip" what is the command in ksh.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2003 11:24 AM
тАО11-20-2003 11:24 AM
Re: String manipulation
s="manipulate"
s1=`expr substr $s 2 4`
echo $s1
Enjoy.. :)
-Brian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2003 02:18 PM
тАО11-20-2003 02:18 PM
Re: String manipulation
Or:
echo "manipulate" | cut -b 2-5
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2003 05:20 PM
тАО11-20-2003 05:20 PM
Re: String manipulation
s=`expr "manipulate" : "^.\(....\).*"`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2003 05:25 PM
тАО11-20-2003 05:25 PM
Re: String manipulation
echo "manipulate" | cut -c2-5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2003 05:51 PM
тАО11-20-2003 05:51 PM
Re: String manipulation
what's about
--------------------------
s=manipulate
echo $s | awk '{print substr($0,2,4)}'
---------------------------
works also with every shell
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-20-2003 06:46 PM
тАО11-20-2003 06:46 PM
Re: String manipulation
OR
echo $s | sed 's|^.\\(...\\).*$|\\1|'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-21-2003 02:06 AM
тАО11-21-2003 02:06 AM
Re: String manipulation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-21-2003 02:54 AM
тАО11-21-2003 02:54 AM
Re: String manipulation
s="manipulate"
typeset -L4 a="${s#??}"
s#?? will return "s" with the first 2 characters stripped. typeset -L4 will put that result into "a", but limit the size to 4 characters.
This technique doesn't work if the extract may be variable.
HTH
-- Rod Hills