Commands by jtgd (1)

  • The above line is the meat of the script. What I do is have a key in uzbl that puts the current URL into the clipboard (use if I am on the YouTube page) or right click a link to a YouTube page, or however you want to get the URL into the clipboard. With xbindkeys I run this from the keyboard. The script: #!/bin/bash # Get URL from command line arg if given, else use clipboard. if [[ "$1" == "" ]] ; then url=$(xclip -o) else url="$1" fi # Strip it down to remove cruft url="${url%%&feature*}" url="${url%%&list*}" url="${url%%&index*}" # optional zenity --warning --timeout=1 --title="Running mplayer" --text="$url" mplayer $(youtube-dl -f best -g "$url" 2>/dev/null) Show Sample Output


    0
    mplayer $(youtube-dl -f best -g "$url" 2>/dev/null)
    jtgd · 2015-03-16 20:54:27 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

Show what PID is listening on port 80 on Linux

Resize a Terminal Window
Replace 70 with the desired height. Replace 180 with the desired width. I put it in my bashrc, because by default my terminal is too small.

tar and remove files which are older that 100 days
tar does not have a -mtime option as find. tar appends all the file to an existing tar file.

Run remote web page, but don't save the results
I have a remote php file that I want to run once an hour. I set up cron to run this wget. I don't really care about what's in the file though, I don't want to save the results, so I run the -O and send it to /dev/null

Broadcast your shell thru ports 5000, 5001, 5002 ...
run 'nc yourip 5000', 'nc yourip 5001' or 'nc yourip 5002' elsewhere will produce an exact same mirror of your shell. This is handy when you want to show someone else some amazing stuff in your shell without giving them control over it.

Oneliner to run commands on multiple servers
Oneliner to run commands on multiple servers over ssh. - First parameter "$1" is the command you want to execute remotely. ( It can be multiple commands e.g. "hostname;uptime") - Second parameter "${@:2}" represents the remote host/s you want to run the command/s on.

lists files and folders in a folder
lists files and folders in a folder with summary.

draw honeycomb
$ tput setaf 1 && tput rev && seq -ws "___|" 81|fold -69|tr "0-9" "_" && tput sgr0 $ $ # (brick wall)

List your sudo rights
List the commands you have the right to use with sudo.

Making scripts runs on backgourd and logging output
Save all output to a log.


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: