Skip to content

Instantly share code, notes, and snippets.

Last active Mar 8, 2019
What would you like to do?

rename entire folder content to ordered filenames

ls | cat -n | while read n f; do mv "$f" "optional_prefix$n.jpg"; done

remove files with odd numbers in the name ending

ls | grep -P '[02468]\.\w*$' | xargs -d "\n" rm

revert the order of ordered filenames

for i in {1..50}; do mv "$i.jpg" "renamed/shirt_$(( 50 - $i + 1 )).jpg"; done

remove some text recursively from you current directory

find ./ -type f -exec sed -i 's/YOUR_WORD_HERE//g' {} \;

test user write permissions

sudo -u <USER_NAME> touch -c </FULL/PATH/HERE.log> 2>&1 > /dev/null | grep 'Permission denied'

test user read permissions

sudo -u <USER_NAME> head -1 </FULL/PATH/HERE.log> 2>&1 > /dev/null | grep 'Permission denied'

delete local branchs that no longer have remote reference (already merged)

git checkout master && git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment