Commands by RiskNerd (3)

  • Recursively compares files in directories DIR and OLD_FILES using dwdiff Word-by-word comparison with dwdiff results in words unique to NEW file versions in the DIR directory tree shown enclosed in [- SQUARE BRACKETS -] and words unique to OLD file versions in the OLD_FILES directory tree shown enclosed in {+ CURLY BRACES +} Note: does not detect files unique to the OLD_FILES directory tree. Show Sample Output


    0
    find DIR -exec sh -c "if [ -f \"{}\" ]; then echo {} >> dwdiff.txt; dwdiff --no-common {} /OLD_FILES/{} >> dwdiff.txt; echo \"--EOF--\" >> dwdiff.txt; fi" \;
    RiskNerd · 2022-02-23 08:52:13 604
  • Use this function with bash version 4+ to convert arbitrary hexadecimal sequences to binary. If you don't have bash 4+ then modify the lowercase to uppercase demangling statement s=${@^^} to set s equal to the uppercase hex input or the bc command throws an input parser error. Show Sample Output


    0
    hex2bin () { s=${@^^}; for i in $(seq 0 1 $((${#s}-1))); do printf "%04s" `printf "ibase=16; obase=2; ${s:$i:1};\n" | bc` ; done; printf "\n"; }
    RiskNerd · 2018-10-02 22:02:33 546
  • Compare the content of the files in the current directory with files of the same name in the duplicate directory. Pop Quiz: You have a duplicate of a directory with files of the same name that might differ. What do you do? You could use diff to compare the directories, but that's boring and it isn't as clever as find -print0 with xargs. Note: You must omit stderr redirect 2>/dev/null to see the list of missing files from DUPDIR, if any. Hint: Redirect stderr to a new file to produce a more readable list of files that are missing from DUPDIR. Warning: This doesn't tell you if DUPDIR contains files not found in the current directory so don't delete DUPDIR. Show Sample Output


    0
    find . -maxdepth 1 -mindepth 1 -print0 | xargs -0 -n 1 -I % cmp % /DUPDIR/% 2>/dev/null
    RiskNerd · 2018-07-08 02:25:57 371

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

Have a smile
Outputs utf-8 smileys

Backup all mysql databases to individual files on a remote server
It grabs all the database names granted for the $MYSQLUSER and gzip them to a remote host via SSH.

Use curl with a local SOCKS5 proxy (e.g. Tor)
Routes curl input through a local SOCKS5 proxy; in this case, anonymizes curl activity via The Onion Router (Tor) proxy running locally. Note that the traffic will be anonymized, but it will NOT be encrypted, so your traffic will be very vulnerable to man-in-the-middle attacks.

Random unsigned integer
works at least in bash. returns integer in range 0-32767. range is not as good, but for lots of cases it's good enough.

determine if tcp port is open

find xargs mv

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Advanced python tracing
Trace python statement execution and syscalls invoked during that simultaneously

Create directory named after current date
Not a discovery but a useful one nontheless. In the above example date format is 'yyyymmdd'. For other possible formats see 'man date'. This command can be also very convenient when aliased to some meaningful name: $ alias mkdd='mkdir $(date +%Y%m%d)'

Upgrade all perl modules via CPAN


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: