Welcome to bashoneliners.com, a growing collection of practical and well-explained Bash tips and tricks. We are committed to review every contributed one-liner to ensure its high quality, practical usefulness, and a solid explanation of how it works. We want to document one-liners for frequent (non-trivial) tasks executed in the shell, written in the best possible way, following good practices known in the industry. To get the latest Bash one-liners, follow @bashoneliners on Twitter. If you find any problems, please report on GitHub Issues.
0 score

Schedule a one-time task using "at" command and intuitive date specifications

 $ at now + 30 minutes

Sept. 25, 2011, 11:30 a.m.Janos

0 score

Aliases the ls command to display the way I like it

 $ alias ls='ls -lhGpt --color=always'

Sept. 22, 2011, 12:25 a.m.versorge

2 score

Remove spaces recursively from all subdirectories of a directory

 $ find /path/to/dir -type d | tac | while read LINE; do target=$(dirname "$LINE")/$(basename "$LINE" | tr -d ' '); echo mv "$LINE" "$target"; done

Sept. 20, 2011, 4:52 p.m.Janos

1 score

Replace a regexp pattern in many files at once

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

Sept. 15, 2011, 11:50 p.m.Janos

0 score

Find video files cached by the flash plugin in browsers

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

Aug. 27, 2011, 1:46 p.m.Janos

0 score

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

Aug. 21, 2011, 1:40 p.m.Janos

0 score

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

Aug. 14, 2011, 9:35 p.m.Janos

0 score

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

Aug. 9, 2011, 9:57 p.m.Janos

0 score

Halt the system in Linux without the halt command or gui

 $ echo o > /proc/sysrq-trigger

Aug. 9, 2011, 9:55 p.m.Janos

0 score
0 score

Create an encrypted tar file with openssl

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

Aug. 9, 2011, 1:30 a.m.Janos

0 score

Make another user superuser in Ubuntu

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

Aug. 5, 2011, 8:57 p.m.Janos

0 score

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

 $ sudo mlabel -i /dev/sdd1 ::NewLabel

Aug. 5, 2011, 8:57 p.m.Janos

0 score

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

Aug. 5, 2011, 8:57 p.m.Janos

2 score

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

Aug. 5, 2011, 8:57 p.m.Janos

0 score

Find Flash videos stored by browsers on a Mac

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

Aug. 5, 2011, 8:57 p.m.Janos