![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add string after another string with special characters | heliode | Shell Programming and Scripting | 2 | 03-21-2008 08:06 AM |
| cutting part of string | dhaval_khamar | Shell Programming and Scripting | 3 | 07-25-2005 10:18 AM |
| Cutting Up a String | lesstjm | Shell Programming and Scripting | 4 | 09-21-2004 11:40 AM |
| Removing characters from end of $string | craig2k | Shell Programming and Scripting | 3 | 03-25-2003 10:38 AM |
| removing characters from end of string | el_toro | Shell Programming and Scripting | 4 | 07-14-2002 08:02 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
CUT command - cutting characters from end of string
Hello,
I need to delete the final few characters from a parameter leaving just the first few. However, the characters which need to remain will not always be a string of the same length. For instance, the parameter will be passed as BN_HSBC_NTRS/hub_mth_ifce.sf. I only need the bit before the slash - BN_HSBC_NTRS. However, this could also be passed as BN_HUB_NTRS/hub_mth_ifce.sf - slightly shorter. Is there a way of removing the /hub_mth_ifce.sf part and storing it as an additional parameter? Thanks, John. |
|
||||
|
Look at the "dirname" and "basename" commands, they should suit you.
Another possibility would be to use the "${var%%/*}" shell expansion: Code:
myvar="abcde/1234"
print - ${myvar%%/*} # will produce "abcde"
Code:
myvar="abcde/1234/xyz"
print - ${myvar%%/*} # will produce "abcde"
print - ${myvar%/*} # will produce "abcde/1234"
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|