Skip to content

Instantly share code, notes, and snippets.

@simongcc

simongcc/batch.sh

Last active Aug 18, 2020
Embed
What would you like to do?
Bash batch file notes
for file in *.po; do
po-to-xls ${file%.*}.po -o ${file%.*}.xlsx
done
# https://stackoverflow.com/questions/2664740/extract-file-basename-without-path-and-extension-in-bash
# $file is the file original name
# no extension: ${file%.*}.po
# s=/the/path/foo.txt
# echo "${s##*/}"
# foo.txt
# s=${s##*/}
# echo "${s%.txt}"
# foo
# echo "${s%.*}"
# foo
# zip folders individually
# https://stackoverflow.com/questions/20452384/how-to-compress-multiple-folders-each-into-its-own-zip-archive
for i in */; do
zip -r "${i%/}.zip" "$i";
done
# test statement
# https://ryanstutorials.net/bash-scripting-tutorial/bash-if-statements.php
# if then
# http://mywiki.wooledge.org/BashFAQ/031
if [ $1 = "load" ]; then
sudo launchctl load /Library/LaunchDaemons/homebrew.custom.httpd.plist
fi
if [ $1 = "unload" ]; then
sudo launchctl unload /Library/LaunchDaemons/homebrew.custom.httpd.plist
fi
if [ $1 = "reload" ]; then
sudo launchctl unload /Library/LaunchDaemons/homebrew.custom.httpd.plist
sudo launchctl load /Library/LaunchDaemons/homebrew.custom.httpd.plist
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.