Commands by billyauhk (1)

  • It handles all possible combination of the hex bytes, including NaNs, Infinities, Normalized and Subnormal Numbers... This crazy DC stuff spent me a few days to write, optimize, polish and squeeze so that it works within the tight 255 character bound... You can modify it easily for other IEEE754 numbers, say, half, double, double-extended, quadruple (I hope someone will find this useful and submit more dc code to commandlinefu!) Show Sample Output


    1
    dc -e"16i?dsH0sq2d17^ss8^dse2/1-stdlsle*/2*2B+an[[ FP Indef.]n]sQ[dls2//2%_2*53+an[NaN]ndle4*1-ls2/*=Q2Q]sN[1sqdls%0<N[oo]n]sMdls/le%dsdle1-=M[[]pq]sPlq1=P[r+0]s0ldd1r0=0lHls%rls*+sS2r^Alt4*^*lS*2lt^/ls/dsSZlt4*-1-sFlsZ1+klSdArZ1-^/dn0=P[e]nlFp"
    billyauhk · 2011-07-27 18:55:20 4

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

Ping all hosts on 192.168.1.0/24
-b option takes the broadcast address.

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

a find and replace within text-based files
using find's exec option instead of a for loop and using sed's -i option for inplace replacement. no need to do the file swap.

Create a file of a given size in linux
If you're trying to create a sparse file, you can use dd by 'skip'ing to the last block instance. ls -ls shows the actual size vs. the reported size

quick and dirty formatting for HTML code
Finds all the closing tags in a HTML document via non-greedy regex and adds a linefeed for easier reading/editing . sed -i.bak -r 's_(/[^>]*?>)_\1\n_g' filename.html . This will save a copy of filename.html as filename.html.bak and then add the linefeeds to the original file

tar the current directory wihtout the absolute path
tars the current directory (and its children) in an archive of the same name (plus ".tar" :)) in the parent directory without the absolute path, so that when the archive is extracted, only the current directory name is created for the path. Assumes bash/zsh.

Create a new file

revert a file with svn

Print a list of standard error codes and descriptions.
Written by jmcnamara Taken from http://www.perlmonks.org/?node_id=274896

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials


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: