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.

Required fields*

4
  • 10
    One-line check in bash: [ -f "${file}" ] && echo "file found" || echo "file not found" (which is the same as if [ ... ]; then ...; else ...; fi).
    – flotzilla
    Commented Oct 1, 2015 at 7:48
  • 2
    Python would be a completely wrong tool for this job on the command line.
    – ruohola
    Commented Oct 25, 2021 at 10:54
  • Hi @ruohola :) I disagree. Commented Oct 26, 2021 at 18:11
  • 1
    On one-liners in Python: "...which makes Python close to useless for command-line one-liner programs ... You can get away with a sequence of simple statements, separated by semi-colon ... as soon as you add a construct that introduces an indented block (like if), you need the line break..." Commented Oct 4, 2022 at 20:08