First, let me say that it is good practice to create a test case that can demonstrate the problem that can be run stand alone. This serves two purposes. First, it means that those trying to help you with your problem spend time on your problem, not on making assumptions about your code. Secondly, you may find the answer yourself while making the test case.
So, although we cannot tell what the answer is from the code you quote, I suggest that you try quoting all your variables as you have done in the statement if [ ! -z "$r1" ]. Filenames with spaces in will cause problems with unquoted variables in this code as it stands.
Main Topics
Browse All Topics





by: omarfaridPosted on 2008-04-22 at 07:19:56ID: 21411336
if [ -f $f1 -a -r $f1 ]
the -f is checking if $f1 is a file , -a means AND -r means is readable (you have read perm on it)
what do you see if you run
ls -l $f1
id
Please post output