tags:

views:

77

answers:

3

I have a directory with full svn backups named like this:

name1.20100412.r9.bz2
name1.20100413.r10.bz2
name2.20100411.r101.bz2
name3.20100412.r102.bz2
...

I need to check if a backup file exists using name and revision number only. I tried test but it didn't work:

if [ -e name1.*.r9.bz2 ]; then echo exists; fi
[: too many arguments

How can I test if file exists?

+2  A: 
if ls name1.*.r9.bz2 > /dev/null;
    then echo exists;
fi
eugene y
+1  A: 

Try something like

FILES=(`ls name1.*.r9.bz2`)
if [ ${#FILES[@]} -gt 0 ]; then
  echo "Files!"
else
  echo "No Files"
fi
Josh Knauer