Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Posts
    106

    Unanswered: 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

  2. #2
    Join Date
    Jan 2004
    Location
    Bordeaux, France
    Posts
    320
    You can do :
    Code:
    # with all shells
    string=`basename $a`
    
    # with Ksh or Bash
    string=${a##*/}
    Jean-Pierre.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •