The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-21-2008
JWilliams JWilliams is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 9
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.
  #2 (permalink)  
Old 01-21-2008
salaathi's Avatar
salaathi salaathi is offline
Registered User
  
 

Join Date: Sep 2007
Location: Madurai
Posts: 20
use awk -F

awk -F/ ' {print $1}' filename > outputfile
  #3 (permalink)  
Old 01-28-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
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"
If your variable contains more than one "/" use the single or the double percent-sign depending on what you want to get:

Code:
myvar="abcde/1234/xyz"
print - ${myvar%%/*}           # will produce "abcde"
print - ${myvar%/*}            # will produce "abcde/1234"
bakunin
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0