Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/josef-friedrich/shell-scripts
A collection of shell scripts.
https://github.com/josef-friedrich/shell-scripts
scripts-collection shell
Last synced: 23 days ago
JSON representation
A collection of shell scripts.
- Host: GitHub
- URL: https://github.com/josef-friedrich/shell-scripts
- Owner: Josef-Friedrich
- License: mit
- Created: 2016-09-08T05:07:01.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-02-03T21:34:46.000Z (11 months ago)
- Last Synced: 2024-02-03T22:29:13.333Z (11 months ago)
- Topics: scripts-collection, shell
- Language: Shell
- Homepage:
- Size: 460 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README-base.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/Josef-Friedrich/shell-scripts.svg?branch=master)](https://travis-ci.org/Josef-Friedrich/shell-scripts)
# shell-scripts
A collection of hopefully useful shell scripts
## Coding style
* Use tabs for indentation
* Prefix functions with _
* Variable names are UPPERCASEExample:
```sh
while getopts ":b:ht" OPT; do
case $OPT in
b)
BODY="$OPTARG"
;;
h)
_usage
;;
t)
SUBJECT="Test mail "
BODY="Sent on $(date) to $MAILLOG_EMAIL."
echo "Sending test mail to $MAILLOG_EMAIL."
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
doneshift $((OPTIND-1))
if [ -z "$SUBJECT" ]; then
SUBJECT="$1"
fiFILE="$2"
if [ -z "$SUBJECT" ]; then
_usage
fiTMP_FILE=/tmp/maillog.sh_$(date +%s)
if [ ! -f "$FILE" ] && [ -n "$BODY" ]; then
echo "$BODY" > $TMP_FILE
FILE=$TMP_FILE
fiif [ ! -f "$FILE" ]; then
FILE=$TMP_FILE
while read DATA; do
echo "$DATA" >> "$FILE"
echo "$DATA"
done
fimail -s "$SUBJECT" $MAILLOG_EMAIL < "$FILE"
```## Standard option `-h` or `--help`
```sh
_usage() {
echo "Usage: $(basename "$0")Options:
-h, --help: Show this help message."
}
``````sh
if [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then
_usage
exit 0
fi
```# Test
Run test with this command: `make test`
---
# Help messages of all scripts