Commands by intangible (1)

  • Instead of hard-coding in a check to scrape info from ifconfig based on a specific interface, do it in a more portable way. This works really well if you switch between wired, wireless, bluetooth or even VPN connections. You can get your current IP in a script (since it'll be something like tun0 instead of eth0 or wlan1). This uses a well known public ip address 8.8.8.8, but it doesn't actually connect to it, it just shows you the route it would take. Show Sample Output


    2
    ip route get 8.8.8.8 2>/dev/null|grep -Eo 'src [0-9.]+'|grep -Eo '[0-9.]+'
    intangible · 2012-10-14 02:06:13 5

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

Get length of current playlist in xmms2

function to compute what percentage of X is Y? Where percent/100 = X/Y => percent=100*X/Y
This function make it easy to compute X/Y as a percentage. The name "wpoxiy" is an acronym of "what percentage of X is Y"

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

1:1 copy of a volume
copies all files from the source disk / (skipping boundaries of mouted -in volumes) to /mnt/mydisk. Logical links are being preserved as well as devices, pipes etc. This can copy a MacOS X or Linux volume and keep it bootable. Note: its not suited to copy files with MacOS 9 style resources.

Converts multiple youtube links to mp3 files
Usage: ytmp3 "YTurl" "YTurl2" "YTurl3" "YTurlN" Uses the shift command to let you extract the .mp3 from as many youtube urls as you like (or wherever else youtube-dl is supported) *Requires youtube-dl Orginal chunk of code: youtube-dl -q -t --extract-audio --audio-format mp3 URL taken from here http://www.commandlinefu.com/commands/view/9701/convert-youtube-videos-to-mp3

what model of computer I'm using?

Check if variable is a number

Backup entire system through SSH

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.

Highlight network TX, RX information change


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: