Commands by kostis (4)

  • This is a standard procedure for me, whenever I set up a new Raspberry Pi system. Because the default user is "pi", I quickly replace it with my own (e.g. "kostis"), but I have to substitute that user to all of pi's groups first, before deleting the default account. xargs helps a lot with that in a single line, while avoiding boring "for" loops. For everything trickier, there's always "parallel" :)

    groups pi | xargs -n 1 | tail -n +4 | xargs -n 1 sudo adduser kostis
    kostis · 2022-01-25 07:20:09 230
  • 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 16
  • 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 215
  • 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 208

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

ffmpeg command that transcodes a MythTV recording for Google Nexus One mobile phone
This command will transcode a MythTV recording. The target device is a Google Nexus One mobile phone. My recordings are from a HDHomerun with Over The Air content. Plays back nicely on the N1.

Using numsum to sum a column of numbers.
if you, like me, do not have the numsum, this way can do the same.

use the previous commands params in the current command
Here the !!:1 will take the first parameter from the previous command. This can be used in conjunction with other history commands like ! and so on.

find out how many days since given date
Exactly the same number of characters, exactly the same results, but with bc

Find non-ASCII and UTF-8 files in the current directory

Test a serial connection
If the connection works you should see a "hello" on host A. If not: check your cabeling etc :-)

The top ten commands you use

rgrep: recursive grep without .svn
Only excludes .svn from filenames.

run a command from within vi without exiting
":! ls -l " results in listing the files in the current directory. pressing "enter" will get you back into vi.

save man-page as pdf

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: