Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

10
  • I suppose I could also use boolean logic to determine the equivalent expression: if ! [ -f file1 ] || ! [ -f file 2 ] || ! [ -f file3 ] ; then but I'd like a more general answer. Commented Dec 3, 2015 at 18:31
  • 1
    You can also negate inside the braces, e. g. if [[ ! -f file1 ]] && [[ ! -f file2 ]]; then Commented Dec 3, 2015 at 18:39
  • 1
    Yes, I just tested if [ ! 1 -eq 2 ] && [ ! 2 -eq 3 ]; then echo yep; fi and it works. I just always write tests with double-braces as a matter of habit. Also, to ensure it's not bash, I further tested if /bin/test ! 1 -eq 2 && /bin/test ! 2 -eq 3 ; then echo yep; fi and it works that way also. Commented Dec 3, 2015 at 18:42
  • 1
    @Wildcard - [ ! -e file/. ] && [ -r file ] will drop directories. negate it as you like. of course, that's what -d does. Commented Dec 3, 2015 at 21:06
  • 2
    Related question (similar but not as much discussion and answers not so helpful): unix.stackexchange.com/q/156885/135943 Commented Dec 3, 2015 at 21:29