Skip to content

Instantly share code, notes, and snippets.

@jescalan
Created January 11, 2012 15:25
Show Gist options
  • Select an option

  • Save jescalan/1595167 to your computer and use it in GitHub Desktop.

Select an option

Save jescalan/1595167 to your computer and use it in GitHub Desktop.
bash file management
# This script is a great shorcut for managing a large number of files.
# It runs through all the files in the present working directory, compares them
# against a regex, and then you can do what you want with the matches
for f in *
do if [[ "$f" =~ some_regex ]]
# do something to the files that match
# this is just an random example that zips them
then zip "$f.zip" $f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment