in reply to One liner to test existance of a file
"perl -e /.firstboot | echo $?"
has a number of problems.
The above should be
q{perl -e'exit(-e "/.firstboot" ?1:0)' | echo $?}
which can be simplified to
q{perl -e'print -e "/.firstboot" ?1:0'}
But why not just use the shell?
q{test ! -e /.firstboot ; echo $?} -or- q{if [ -e /.firstboot ] ; then echo 1 ; else echo 0 ; fi}
Also, you didn't specify what should be returned when it cannot be determined whether the file exists or not.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: One liner to test existance of a file
by kamal (Sexton) on Jul 15, 2010 at 01:02 UTC | |
by ikegami (Patriarch) on Jul 15, 2010 at 02:55 UTC |