Commands by unixmonkey63215 (1)

  • Requires ImageMagick. Extracts date taken from image and renames it properly. Based on StackOverflow answer. Show Sample Output


    0
    for fil in *.JPG; do datepath="$(identify -verbose $fil | grep DateTimeOri | awk '{print $2"_"$3 }' | sed s%:%_%g)"; mv -v $fil $datepath.jpg; done
    unixmonkey63215 · 2013-08-02 01:42:04 8

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

Print permanent subtitles on a video (international edition :) )
If it's Hebrew [most probably all RTL languages. Comments?], add -flip-hebrew and -noflip-hebrew-commas to the mplayer switches: $ transcode -i myvideo.avi -x mplayer="-utf8 -flip-hebrew -noflip-hebrew-commas -sub myvideo.srt" -o myvideo_subtitled.avi -y xvid

what model of computer I'm using?

grep -v with multiple patterns.
You can use -e to pass multiple patterns.

Log colorizer for OSX (ccze alternative)
Download colorizer by @raszi @ http://github.com/raszi/colorize

Using a single sudo to run multiple && arguments
This will also work with bash instead of sh shell sudo bash -c 'apt update -y && apt upgrade -y'

Stream audio over ssh
This one doesn't need to convert to wav.

Delete Last Line of a File if it is Blank
Use sed to remove the last line of a file only if it is empty.

Find files recursively that were updated in the last hour ignoring SVN files and folders.
Find files recursively that were updated in the last hour ignoring SVN files and folders. Incase you do a full svn up on accident.

Convert files from DOS line endings to UNIX line endings
The old dos2unix from sysutils has been deprecated on Debian systems to this tool.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }


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: