What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands using touch from sorted by
Terminal - Commands using touch - 50 results
find . -exec touch {} \;
touch file
touch /path/to/file.txt
for file in $(find ~/ -iname "*.mp3");do c=$(mp3info $file|grep Genre|cut -f 3 -d :|cut -f 2 -d " ");if [ -z "$c" ];then c="Uncategorized";fi;if [ ! -e $c ];then touch $c.m3u;fi;echo "$file">>$c.m3u;done
find . -type f | while read line; do NEW_TS=`date -d@$((\`stat -c '%Y' $line\` + <seconds> )) '+%Y%m%d%H%M.%S'`; touch -t $NEW_TS ${line}; done
2010-11-18 14:03:32
User: angleto
Functions: find read touch

Increase the modification date for the files selected with the find command.

touch -t "YYYYMMDDhhmm.ss" ~/.ts ; find . -newer ~/.ts
2010-10-26 19:45:32
User: poffey21
Functions: find touch

This is great for looking for files that have been updated recently. Logs especially or monitoring what files were added during an install.

read -p "enter url:" a ; w3m -dump $a > /dev/shm/e1q ; less /dev/shm/e1q ; read -p "save file as text (y/n)?" b ; if [ $b = "y" ] ; then read -p "enter path with filename:" c && touch $(eval echo "$c") ; mv /dev/shm/e1q $(eval echo "$c") ; fi ; echo DONE
2010-07-13 22:36:38
User: LinuxMan
Functions: c++ echo eval less mv read touch

Thanks th John_W for suggesting the fix allowing ~/ to be used when saving a directory.


Type in a url, it will show a preview of what the file will look like when saved, then asks if you want to save the preview and where you want to save it. Great for grabbing the latest commandlinefu commands without a full web browser or even a GUI. Requires: w3m

touch file-$(date +%Y%m%d)
find . \( -type d -empty \) -and \( -not -regex ./\.git.* \) -exec touch {}/.gitignore \;
for i in `seq 100`;do mkdir f{1..100} touch myfile$i mv myfile$i f$i;done
touch -t "YYYYMMDDhhmm.ss" dummy ; find . -anewer dummy
2009-11-21 04:05:45
Functions: find touch

touch a dummy file with the specified date, then use find with -anewer .

sudo touch /forcefsck
2009-10-29 17:04:47
User: johnraff
Functions: sudo touch

The empty file /forcefsck causes the file system check fsck to be run next time you boot up, after which it will be removed.

This works too:

sudo >/forcefsck
touch -r "$FILE1" "$FILE2"
2009-10-21 13:53:59
User: kobayashison
Functions: touch

atime and mtime timestamps of $FILE2 is changed according to the ones of $FILE1. If $FILE2 doesn't exist is created.

touch /tmp/file ; $EXECUTECOMMAND ; find /path -newer /tmp/file
2009-08-31 18:47:19
User: matthewdavis
Functions: find touch

This has helped me numerous times trying to find either log files or tmp files that get created after execution of a command. And really eye opening as to how active a given process really is. Play around with -anewer, -cnewer & -newerXY

touch $2;firefox -print $1 -printmode PNG -printfile $2
2009-08-04 06:55:25
User: pamirian
Functions: touch

This requires the command-line print extension (see #2861 for more details). I use it to make up complex images with formatted text using CSS and whatnot. It's a lot slicker than imagemagick for certain things. Now imagine using a local webserver with PHP and a database to generate the images. Oh, the possibilities...

touch $2;firefox -print $1 -printmode PDF -printfile $2
2009-08-04 06:40:55
User: pamirian
Functions: touch

This uses the "command-line print" plugin for Firefox (http://torisugari.googlepages.com/commandlineprint2). This same plugin can also produce PNGs. On *nix, the file must exist; therefore the touch bit in front. Also, firefox seems to ignore saved user preferences when "printing" this way (margins, header, footer, etc.), so I had to tweak my ~/.mozilla/firefox/xxxxxxxx.default/prefs.js file by hand. Yup, that's *prefs.js* not user.js - apparently, firefox ignores my user.js file too...

touch -amct [[CC]YY]MMDDhhmm[.ss] FILE
2009-05-27 14:33:22
User: sharfah
Functions: touch

-a for access time, -m for modification time, -c do not create any files, -t timestamp

touch /etc/nologin
2009-04-29 19:43:14
User: udim
Functions: touch
Tags: login

Also with optional message:

echo "no login for you" > /etc/nologin

(This doesn't affect your current X session - you're already logged in!)

touch {1..10}.txt
2009-03-09 12:54:45
User: slaney
Functions: touch

Sometimes I need to create a directory of files to operate on to test out some commandlinefu I am cooking up. The main thing is the range ({1..N}) expansion.

touch /tmp/$$;for N in `seq -w 0 7777|grep -v [89]`; do chmod $N /tmp/$$; P=`ls -l /tmp/$$ | awk '{print $1}'`; echo $N $P; done;rm /tmp/$$
doloop() { DONT=/tmp/do-run-run-run; while true; do touch $DONT; (sleep 30; rm $DONT;) & $1 ; if [ -e $DONT ]; then echo restarting too fast; return ; fi ; done }
2009-02-21 02:11:18
User: evil_otto
Functions: echo return rm sleep touch

This runs a command continuously, restarting it if it exits. Sort of a poor man's daemontools. Useful for running servers from the command line instead of inittab.

touch balls
touch <filename>
touch /forcefsk
touch -acm yyyymmddhhMM.ss [file]
2009-02-05 21:07:09
User: wwest4
Functions: touch

...changes modify time and access time. also:

touch -r [file1] [file2] # make file2 timestamp match file1