Commands by kostis (3)

  • As an alternative to the above command, this one ditches the unnecessary and complicated for loop in favor of a way faster multi-core approach for a task that's more CPU than I/O intensive, making it a perfect suite for GNU parallel

    parallel cwebp -q 80 {} -o {.}.webp ::: *.png
    kostis · 2018-12-07 23:37:24 1
  • You could have that little benchmark run on all cores in parallel, as a multi-core benchmark or stress test First find the number of cores, then have parallel iterate over that in, well, parallel Show Sample Output

    time cat /proc/cpuinfo |grep proc|wc -l|xargs seq|parallel -N 0 echo "2^2^20" '|' bc
    kostis · 2018-12-06 05:36:55 0
  • Broken in two parts, first get the number of cores with cat /proc/cpuinfo |grep proc|wc -l and create a integer sequence with that number (xargs seq), then have GNU parallel loop that many times over the given command. Cheers! Show Sample Output

    time cat /proc/cpuinfo |grep proc|wc -l|xargs seq|parallel -N 0 echo "scale=4000\; a\(1\)\*4" '|' bc -l
    kostis · 2018-12-06 05:15:24 2

What's this? 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

Rename files in batch

Clean way of re-running bash startup scripts.
This replaces the current bash session with a new bash session, run as an interactive non-login shell... useful if you have changed /etc/bash.bashrc, or ~/.bashrc If you have changed a startup script for login shells, use $ exec bash -l Suitable for re-running /etc/profile, ~/.bash_login and ~/.profile. edit: chinmaya points out that $ env - HOME=$HOME TERM=$TERM bash -s "exec bash -l" will clear any shell variables which have been set... since this verges on unwieldy, might want to use $ alias bash_restart='env - HOME=$HOME TERM=$TERM bash -s "exec bash -l"'

find and delete empty directories recursively
this will show the names of the deleted directories, and will delete directories that only no files, only empty directories.

Put a console clock in top right corner
Gives not only date but also some interesting status about the System

Quickly graph a list of numbers
Useful when you've produced a large file of numbers, and want to quickly see the distribution. The value of y halfway along the x axis is the median. Simple! Just create the listOfNumbers.txt file with a number on each line to try it out.

Pull git submodules in parallel using GNU parallel
Make sure to run this command in your git toplevel directory. Modify `-j4` as you like. You can also run any arbitrary command beside `git pull` in parallel on all of your git submodules.

Find the package that installed a command

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

count how many cat processes are running

concatenate avi files
concatenates avi files

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.


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: