Skip to content

Instantly share code, notes, and snippets.

@goooooouwa
Last active August 25, 2023 06:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goooooouwa/b7b6c2edbec3520a9b0a to your computer and use it in GitHub Desktop.
Save goooooouwa/b7b6c2edbec3520a9b0a to your computer and use it in GitHub Desktop.
daily bash script samples
#!/bin/bash
# For loop to exeute some task multiple times
for i in Item1 Item2 ItemN; do
bash ~/task.sh ${i}
done
for i in {1..10}
do
wget https://static.generated.photos/vue-static/human-generator/poses/female/00$i.png
done
# use git conbined with sed/awk to automate text processing tasks
eval "find app/ -type f -exec sed -i 's/target/replacement/g' {} \;"
git diff
echo -n "Here be dragons. Continue?"
read REPLY
if [[ "$REPLY" =~ ^[Yy]$ ]]
then
git add .
git cm "processing $1 complete"
fi
# add namespace to all models
find app/models/ -type f -exec sed -i "1 i module MyModule" {} \;
find app/models/ -type f -exec sed -i "$ a end" {} \;
# you can also automate code indentation, see https://gist.github.com/goooooouwa/d5f40319ab7fb80a7fe4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment