ningy
1
I am trying to check if files staring with filename but ending with diffent dates e.g. filename.2011-10-25.
The code I am using is below
if [ ! -f ~/filename.* ]
It works find only if one file is present but returns binary operator expected
when there are mulptiple files.
Please help me correcting it. I wanna use if statement only.
TIA
Not sure if this is what you're looking for but you can use a loop like:
for file in filename.*
do
....
done
ningy
3
Hi Franklin
Thanks for the reply ... But I need to use if statement as I have another if condition to && with it..
CarloM
4
What shell are you using, and what are you actually trying to do?
vbe
5
It is quite normal since that test is for "file" and file is one... So what is to follow?
works fine for me,is that what you are trying
$ ls -1
a.1024
a.1025
c
$if [ ! -f ~/a.* ]
> then
> echo "success"
> else
> echo "fail"
> fi
fail
Since there are 2 files , it will give message as fail, Does this help ?