bashoneliners.com

Welcome to bashoneliners.com, a curated collection of practical and well-explained Bash one-liners, snippets, tips and tricks. We aim to make each published one-liner to be of high quality: useful, easy to read, follows best practices, with clear, detailed, accurate explanation. These one-liners should help you automate tasks, troubleshoot problems, whether it be in system administration, file management, networking or programming.

Print the list of your Git commits this month

git log --since='last month' --author="$(git config user.name)" --oneline

February 25, 2019bashoneliners

Scan entire Git repo for dangerous Amazon Web Service IDs

git grep -Ew '[A-Z0-9]{20}'

September 5, 2018bashoneliners

Perform git commit with a random message from whatthecommit.com

git commit -m "$(w3m whatthecommit.com | head -n 1)"

January 5, 2018Jab2870

List the content of a GitHub repository without cloning it

svn ls https://github.com/user/repo/trunk/some/path

May 21, 2017bashoneliners

List status of all Git repositories

find ~ -type d -name .git | sed 's?/\.git$??' | awk '{ print "-------------------------"; print "\033[1;32mGit Repo:\033[0m " $0; system("git --git-dir=\""$0"\"/.git --work-tree=\""$0"\" status")}'

October 16, 2016uMt

Test git archive before actually creating an archive // fake dry run

git archive master some/project/subdir | tar t

December 22, 2015openiduser146

Remove .DS_Store from the repository you happen to staging by mistake

find . -name .DS_Store -exec git rm --ignore-unmatch --cached {} +

February 22, 2014Kuwana

Add all unknown files in a Subversion checkout

svn add . --force

September 24, 2013bashoneliners

Export a git project to a directory

git archive master | tar x -C /path/to/dir/to/export

January 12, 2012bashoneliners

Remove all the versioned-but-empty directories from a Subversion checkout

find . -name .svn -type d | while read ss; do dir=$(dirname "$ss"); test $(ls -a "$dir" | wc -l) == 3 && echo "svn rm \"$dir\""; done

November 27, 2011bashoneliners

Delete unversioned files in a Subversion checkout directory and all subdirectories

svn st | grep ^? | sed -e 's/^? *//' | xargs -i{} echo rm -fr "{}"

October 3, 2011janos

Mirror from one Subversion repository to another Subversion repository

bzr co https://repo1/proj1/trunk proj1 && cd proj1 && bzr push https://repo2/vendor/proj1/trunk

August 5, 2011bashoneliners