Skip to content

Instantly share code, notes, and snippets.

@arnoldc
Last active December 15, 2023 11:43
Show Gist options
  • Save arnoldc/bf88869799ea8703be642ff63735245a to your computer and use it in GitHub Desktop.
Save arnoldc/bf88869799ea8703be642ff63735245a to your computer and use it in GitHub Desktop.
[Bashscript] General Tips
1. Command to add to recognize the file type
#!/bin/bash
use .sh extension
########################################
2. To test if file exists
test -e random-file.pdf && echo "EXISTS" || echo "NOT EXISTS"
outputs:
EXISTS
########################################
3. To see if library is installed
comand -v node
outputs:
/usr/local/bin/node
########################################
4. if else syntax
if command -v node; then
echo "node is installed"
else
echo "node is not installed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment