Skip to content

Instantly share code, notes, and snippets.

@antoni
Created May 21, 2015 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoni/6755fc1be9dcd36a5995 to your computer and use it in GitHub Desktop.
Save antoni/6755fc1be9dcd36a5995 to your computer and use it in GitHub Desktop.
Various bash scripts
# (1) mv with regexp
for i in *; do mv -n "$i" "${i/_*dpi*}".png; done;
# (2) Loop over array of strings
declare -a arr=("element1" "element2" "element3")
## now loop through the above array
for i in "${arr[@]}"
do
echo "$i"
# or do whatever with individual element of the array
done
# Access them using echo "${arr[0]}", "${arr[1]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment