
April 4th, 2012, 01:21 PM
|
|
Registered User
|
|
Join Date: Apr 2012
Posts: 2
Time spent in forums: 56 m 51 sec
Reputation Power: 0
|
|
|
Script to display File name in a directory and not sub-directories
I am trying to write a simple Korn Shell script that displays the file name of a csv file. I don't want it to display any csv files name in sub-directories that are under the directory that has the csv file name I want to display
My script name is called test_datafilename.ksh It contains the following
#!/usr/bin/ksh
DIR=/appl/pub/downloads/hrdata/data/Legacy/CombinedFile
FILE=`find $DIR -name "*.csv" |awk -F/ '{print $NF}'`
if [ -f $DIR/$FILE ]
then
print "$FILE was found"
else
print "Nothing Found"
fi
The file name that is located in the Directory is CombinedOriginationwithUpdates_04-2012.csv
and there is a file named
CombinedOriginationwithUpdates_02-2012.csv
in the sub-directory that I do not want to display.
However, when I run the script on my UNIX system it always returns the Else statement from my IF/Then/Else above
/scripts>./test_datafilename.ksh
Nothing Found
What am I doing wrong?
|