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 get file name in given listing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-19-04, 01:32
mariadasun mariadasun is offline
Registered User
 
Join Date: Nov 2004
Posts: 26
Question 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 01:36. Reason: question was wrong
Reply With Quote
  #2 (permalink)  
Old 11-19-04, 06:00
ducasio ducasio is offline
Registered User
 
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
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