Confirming a string

Hi Guys,

I have files that are sent to me in this format:

Copy of USer Database updated 23 JANUARY 2013.csv

I am developing a script to load these files to my database automatically whenever I get these files:

How do I verify these files in an if statement if I do have these files?

if [ -e  'Copy of USer Database updated 23 JANUARY 2013.csv' ]

then

But the issue is that I need to have something like this:

if [ -e Copy of USer Database updated* ]

or something similar

But it does not seem to be possible, I tried these

ls -ltrh 'Copy of USer Database updated*'

ls: Copy of USer Database updated*: No such file or directory

Please Help...

Thanks in advance.

Are you sure this is the name of your file

Copy of USer Database updated 23 JANUARY 2013.csv

I don't think shell can read this file. It should be like this

Copy_of_USer_Database_updated_23_JANUARY_2013.csv

.

In which directory you have this file. Check that directory and give

ls

. And let us know what your are getting.

Try:

ls -ltrh 'Copy of USer Database updated'*

or:

exists() {
  [ -e "$1" ]
}

if exists 'Copy of USer Database updated'*
then
  ..

Hi
this is one way

ls Copy\ of\ USer\ Database\ updated*.csv   > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "File exists"
else
echo "File not exists"
fi

As a very wild guess, are you sure that you have the correct name. Have you tried:

if [ -e  'Copy of User Database updated 23 JANUARY 2013.csv' ]

If this doesn't solve the problem, please show us the output from the command:

ls -ld Copy*

Try this

 
ls -ltrh 'Copy of USer Database updated'*