bashoneliners.com

Welcome to bashoneliners.com, a growing collection of practical and well-explained Bash one-liners, snippets, tips and tricks. We review and improve every contributed one-liner to make sure it is 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.

1

Replace a regexp pattern in many files at once

vi +'bufdo %s/pattern/replacement/g | update' +q $(grep -rl pattern /path/to/dir)

September 15, 2011bashoneliners

0

Find video files cached by the flash plugin in browsers

file /proc/*/fd/* 2>/dev/null | grep Flash | cut -f1 -d:

August 27, 2011bashoneliners

0

Force the preferred language when downloading a web page with wget

wget -–header='Accept-Language: en-us' http://www.timeanddate.com/calendar/index.html?year=2008&country=26 -O calendar.html

August 21, 2011bashoneliners

0

Burn the contents of a directory to dvd without needing a gui application

growisofs -dvd-compat -Z /dev/scd0 -R -J -pad /path/to/dir

August 14, 2011bashoneliners

0

Convert all flac files in the current directory to mp3 format using "lame"

for i in *.flac; do flac -c -d "$i" | lame -m j -b 192 -s 44.1 - "${i%.flac}.mp3"; done

August 9, 2011bashoneliners

0

Halt the system in Linux without the halt command or gui

echo o > /proc/sysrq-trigger

August 9, 2011bashoneliners

0

Create an encrypted tar file with openssl

tar c paths_to_files_and_dirs | gzip -c | openssl des3 > encrypted.tar.gz

August 9, 2011bashoneliners

0

Find Flash videos stored by browsers on a Mac

find /private/ 2>/dev/null | grep /Flash

August 5, 2011bashoneliners

2

Rename all files in a directory to lowercase names

paste <(ls) <(ls | tr A-Z a-z) | while read OLD NEW; do echo mv -v $OLD $NEW; done

August 5, 2011bashoneliners

0

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

0

Change the label of a USB drive in Linux without a gui

sudo mlabel -i /dev/sdd1 ::NewLabel

August 5, 2011bashoneliners

0

Make another user superuser in Ubuntu

for i in $(grep :boss /etc/group | cut -f1 -d:); do adduser wife $i; done

August 5, 2011bashoneliners