Commands by zed (11)

  • Change the value of p to match the path where you wish to create the profile. To run it again in the future, use the parameter --user-data-dir (which gets echoed to you when run): chromium-browser --user-data-dir=/path/to/your/ Quick Functions: # create a new chromium profile new-chromium-profile() { p=~/.config/chromium/$1; cp -r ~/.config/chromium/Default $p && echo "chromium-browser --user-data-dir=$p" && chromium-browser --user-data-dir=$p; } # runs a chromium profile run-chromium-profile() { chromium-browser --user-data-dir=~/.config/chromium/$1; } Show Sample Output


    -1
    p=~/.config/chromium/zed; cp -r ~/.config/chromium/Default $p && echo "chromium-browser --user-data-dir=$p" && chromium-browser --user-data-dir=$p;
    zed · 2010-11-08 02:45:29 4
  • Create a progress dialog with custom title and text using zenity. Show Sample Output


    3
    for i in $(seq 0 5 100); do echo $i; sleep 1; done | zenity --progress --title "Installing Foobar" --text "Pleae wait until process has finished."
    zed · 2010-10-08 04:08:33 2
  • using seq inside a subshell instead of a bash sequence to create increments. Show Sample Output


    3
    for i in $(seq 0 5 100); do echo $i; sleep 1; done | dialog --gauge "Install..." 6 40
    zed · 2010-10-08 04:08:17 3
  • A more robust password creation utility # Create passwords in batch makepasswd --char=32 --count=10 # To learn more about the options you can use man makepasswd Show Sample Output


    -1
    makepasswd --char=32
    zed · 2010-09-29 06:01:32 3
  • Changes your desktop background image in gnome. Update the directory to wherever you keep your wallpapers. I like to create a sub-directory in my Wallpaper folder called "cycle" that I use to define the wallpapers I wish to loop in cron. ex: gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$(find ~/Wallpapers/cycle -type f | shuf -n1)" Show Sample Output


    2
    gconftool-2 -t str -s /desktop/gnome/background/picture_filename "$(find ~/Wallpapers -type f | shuf -n1)"
    zed · 2010-09-21 04:01:55 3
  • Take a screenshot of the focused window with a 4 second countdown # shorten by adding to your .bashrc: alias sss='scrot -ucd4 && eog $(ls -tr | tail -n1)' echo -e "\nalias sss='scrot -ucd4 && eog $(ls -tr | tail -n1)'" >> ~/.bashrc -d 4 second delay -c display countdown -u focused window man scrot for more flags Show Sample Output


    6
    scrot -ucd4 -e 'eog $f'
    zed · 2010-09-15 03:31:06 10
  • requires "youtube-dl" -- sure you can do this with wget and some more obscurity but why waste your time when this great tool is available? the guts consist of mplayer converting a video to a gif -- study this command and read the man page for more information mplayer video.flv -ss 00:23 -endpos 6 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound generates a 6 second gif starting at 23 seconds of play time at 5 fps and a scale of 400x300 start time (-ss)/end time (-endpos) formats: 00:00:00.000 end time should be relative to start time, not absolute. i.e. -endpos 5 == seconds after 0:42 = 0:47 end point play with fps and scale for lower gif sizes the subshell is a solution for the -b flag on youtube-dl which downloads the best quality video, sometimes, which can be various video formats $(ls ${url##*=}*| tail -n1) Show Sample Output


    12
    url=http://www.youtube.com/watch?v=V5bYDhZBFLA; youtube-dl -b $url; mplayer $(ls ${url##*=}*| tail -n1) -ss 00:57 -endpos 10 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound
    zed · 2010-07-18 02:11:39 36
  • The above is an example of grabbing only the first column. You can define the start and end points specifically by chacater position using the following command: while read l; do echo ${l:10:40}; done < three-column-list.txt > column-c10-c40.txt Of course, it doesn't have to be a column, or extraction, it can be replacement while read l; do echo ${l/foo/bar}; done < list-with-foo.txt > list-with-bar.txt Read more about parameter expansion here: http://wiki.bash-hackers.org/syntax/pe Think of this as an alternative to awk or sed for file operations


    1
    while read l; do echo ${l%% *}; done < three-column-list.txt > only-first-column.txt
    zed · 2010-07-09 03:42:56 3
  • The above is just a prove of concept based around the nested bash substitution. This could be useful in situations where you're in a directory with many filetypes but you only want to convert a few. for f in *.bmp *.jpg *.tga; do convert $f ${f%.*}.png; done or you can use ls | egrep to get more specific... but be warned, files with spaces will cause a ruckus with expansion but the bash for loop uses a space delimited list. for f in $(ls | egrep "bmp$|jpg$|tga$"); do convert $f ${f%.*}.png; done I'm guessing some people will still prefer doing it the sed way but I thought the concept of this one was pretty neat. It will help me remember bash substitutions a little better :-P Show Sample Output


    8
    for f in t1.bmp t2.jpg t3.tga; do echo ${f%.*}.png; done
    zed · 2010-07-09 00:38:53 3
  • You need to have fortune and cowsay installed. It uses a subshell to list cow files in you cow directory (this folder is default for debian based systems, others might use another folder). you can add it to your .bashrc file to have it great you with something interesting every time you start a new session. Show Sample Output


    10
    fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
    zed · 2010-07-08 02:57:52 8
  • This will be seen through your system's visual notification system, notify-osd, notification-daemon, etc. --- sleep accepts s,m,h,d and floats (date; sleep .25m; date) --- notify-send (-t is in milliseconds && -u low / normal / critical) man notify-send for more information --- notification-daemon can use b/i/u/a HTML


    5
    sleep 6s && notify-send -t 10000 -u critical "remember to think" &
    zed · 2010-07-01 02:17:24 12

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

Chronometer in hour format
Shorter and faster...

Rename files in batch

Find Duplicate Files (based on size first, then MD5 hash)
If you have the fdupes command, you'll save a lot of typing. It can do recursive searches (-r,-R) and it allows you to interactively select which of the duplicate files found you wish to keep or delete.

Sort dotted quads
Sort a list of IPV4 addresses in numerical order. Great as a filter, or within vim using !}

Record microphone input and output to date stamped mp3 file
record audio notes or meetings requires arecord and lame run mp3gain on the resulting file to increase the volume / quality ctrl-c to stop recording

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

MPD + Digitally Imported
1.- Enter into the playlist path. 2.- Run the command. 3.- Playlists created!

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" }

Get fully qualified domain names (FQDNs) for IP address with failure and multiple detection

Fixes Centos 6.2 yum's metalink certificate errors
Fix's centos 6.2 yum's error: could not get metalink https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=x86_64 error was 14: PYCURL ERROR 77 - "Problem with the SSL CA cert (path? access rights?)" Error: Cannot retrieve metalink for repository: epel-source. Please verify its path and try again


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: