Skip to content

Instantly share code, notes, and snippets.

@betabong
Last active September 11, 2018 12:57
Show Gist options
  • Save betabong/fbf60282005893470cba14249da610a5 to your computer and use it in GitHub Desktop.
Save betabong/fbf60282005893470cba14249da610a5 to your computer and use it in GitHub Desktop.

Terminal Commands

Files

Find and execute with pipes:

find . -name \*.erb -print | xargs -n1 rm

Remove recursively custom icons (Mac OS X):

find . -exec setfile -a c {} \;

Remove hidden SVN directories:

find . -type d -name .svn -exec rm -rf {} \;

Relink Symbolic Link:

ln -n -f -s new/destination path/to/link

Combine text files:

cat file1.txt file2.txt file3.txt > all.txt

Count files by extension:

find source/templates/ -type f | sed 's/.*\.//' | sort | uniq -c

Append string to file:

echo "\nto be prepended" >> text.txt

Prepend string to file:

echo -e "to be prepended\n$(cat text.txt)" > text.txt

Bulk change indentation (from spaces to tabs):

find . -name "*.json" | while read line; do unexpand -t 2 $line > $line.new; mv $line.new $line; done

Bulk change indentation (from tabs to spaces):

find . -name "*.json" | while read line; do expand -t 2 $line > $line.new; mv $line.new $line; done

Other

Ruby Command line:

irb

Mac

Fix usr/local permissions

sudo chown -R "$USER":admin /usr/local

Clear User Font Cache (Mac OS X):

atsutil databases -removeUser
atsutil server -shutdown
atsutil server -ping

Disable local Time Machine backups (only needed for laptops)

sudo tmutil disablelocal
@betabong
Copy link
Author

Jenkins: Jenkins.instance.getItemByFullName('swiss-feature').builds.findAll { it.previousBuild && (it.previousBuild.timestamp.format('M-d-yyyy') == it.timestamp.format('M-d-yyyy'))}.each { it.delete() }

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