The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-10-2009
crackthehit007 crackthehit007 is offline
Registered User
  
 

Join Date: Feb 2009
Location: Pune/Banagalore
Posts: 71
want only file names (not whole path) in shell script

hi i wrote following script,
#!/usr/bin/sh
for index in `ls /tmp/common/*.txt`
do
echo "$index"
done

here index is giving full path but in my program i want only file names (not along with whole path)

Eg. if in /tmp/common files are a.txt and b.txt den out should be a.txt b.txt

and not like ==> /tmp/common/a.txt /tmp/common/b.txt

any knows how to do it?