Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Posts
    26

    Question Unanswered: how to get file name in given listing

    hi

    i writing script which includes getting files in directroy with path.

    storing in file.

    for some instance i need only filename , how can i extract from it.

    or
    is there any way to get only file name if i use command like

    ls -al a/b/c/xyz.jar


    i want only file name to be displayed not the path of file. pls help me...


    Advanced thanks
    Last edited by mariadasun; 11-19-04 at 02:36. Reason: question was wrong

  2. #2
    Join Date
    Aug 2004
    Location
    Rome, Italy
    Posts
    81
    Hi,
    briefly I can tell you to use the command basename, e.g.

    basename /home/username/sh/myscript.sh

    and the result will be: myscript.sh

    in a short fome you can do:

    FILE_NAME=$(basename $FULL_PATH_NAME)


    I hope it works for you.

    bye, bye,
    ducasio

Posting Permissions

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