- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- remove the last field from a string
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
Forums
Discussions
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
09-06-2002 02:04 PM
09-06-2002 02:04 PM
I have a string like the following
$BACD_APPL/xyz/abc/abc.txt
Now I need to print the string on the screen without the last field (abc.txt)
i.e. the output should be $BACD_APPL/xyz/abc/
I was able to do it using cut and sed, but it comes as two commands. Is any body has single line command solution.
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2002 02:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2002 02:16 PM
09-06-2002 02:16 PM
Re: remove the last field from a string
x=/xyz/abc/abc.txt
echo ${x%/*}
will display
/xyz/abc
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2002 04:54 PM
09-06-2002 04:54 PM
Re: remove the last field from a string
And don't forget you can use
basename
to grab the last portion off:
abc.txt
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2002 10:16 PM
09-06-2002 10:16 PM
Re: remove the last field from a string
/W 56 > foreach i ( /W/sv.txt )
foreach? echo "r" $i:r
foreach? echo "e" $i:e
foreach? echo "t" $i:t
foreach? echo "h" $i:h
foreach? end
r /W/sv
e txt
t sv.txt
h /W
/W 57 >