- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- who do I do a substr ?
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
12-04-2002 05:01 PM
12-04-2002 05:01 PM
I always want the first 3 characters, so the result should always be "tad".
How do I get the first 3 characters from variableX ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 05:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 05:41 PM
12-04-2002 05:41 PM
Re: who do I do a substr ?
I knew it was an easy one; I was having the worst luck with awk:
works here:
df -k /u100 | sed '1d' | awk '{print $5}' | awk '{printf "%02d\n", $1}'
but not here !:
(given: x=tad4)
echo $X | awk '{printf "%03d\n", $1}'
Can you shed some light on the above 2 -thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2002 07:47 PM
12-04-2002 07:47 PM
Re: who do I do a substr ?
or you could use sed, sed 's/\(...\).*/\1/'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2002 12:04 AM
12-05-2002 12:04 AM
Re: who do I do a substr ?
Precompiled version available for HP-UX 11.00 and 10.20 on my ITRC site: https://www.beepz.com/personal/merijn/#Downloads
di has an option to spit out it's info in an easy to parse format.
Once used to di you never want to use df or dbf anymore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2002 06:50 AM
12-06-2002 06:50 AM
Re: who do I do a substr ?
>a="tadf"
>b="${a%?}"
>print $a
tadf
>print $b
tad
Scott Williams