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.

4
  • This would still execute echo $amount >>manual-entry no matter what the input is. That may not be what OP is looking for Commented May 2, 2019 at 18:20
  • indeed, I'd rewrite as if [[ "$amount" -gt 0 ]]; then echo "$amount" >> manual-entry; else echo "Echo a positive integer"; fi, or possibly use an until loop rather than a single if/then test. Commented May 2, 2019 at 18:33
  • @Jesse_b This can be fixed by adding && exit 0 after the echo Commented May 2, 2019 at 18:34
  • @DougO'Neal: In this case it's likely fine but it's generally bad practice to chain more than one && or || in a single list. I would recommend an if construct as DopeGhoti suggested. Commented May 2, 2019 at 18:36