If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how to pass a string to awk command

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-07-04, 10:37
sachin_mt sachin_mt is offline
Registered User
 
Join Date: Jan 2003
Posts: 106
how to pass a string to awk command

Hi,

in a shell program I have a string in a variable say

a="/opt/casp/asp-server-3000"

now I need to extract asp-server-3000 from this,I mean I need the part of string which comes after the last slash / in the string a.

How can i do this using awk or grep etc etc.
I need the exact command pl.
__________________
Sachi
Reply With Quote
  #2 (permalink)  
Old 04-07-04, 10:41
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
You can do :
Code:
# with all shells
string=`basename $a`

# with Ksh or Bash
string=${a##*/}
__________________
Jean-Pierre.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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