Commands using rev (16)

  • usage: sitepass MaStErPaSsWoRd example.com description: An admittedly excessive amount of hashing, but this will give you a pretty secure password, It also eliminates repeated characters and deletes itself from your command history. tr '!-~' 'P-~!-O' # this bit is rot47, kinda like rot13 but more nerdy rev # this avoids the first few bytes of gzip payload, and the magic bytes. Show Sample Output


    13
    sitepass() { echo -n "$@" | md5sum | sha1sum | sha224sum | sha256sum | sha384sum | sha512sum | gzip - | strings -n 1 | tr -d "[:space:]" | tr -s '[:print:]' | tr '!-~' 'P-~!-O' | rev | cut -b 2-11; history -d $(($HISTCMD-1)); }
    grokskookum · 2009-10-01 20:14:57 12

  • 4
    echo "$USER"|rev | espeak
    bugmenot · 2016-05-26 16:10:20 12
  • In the above example 'muspi merol' (the output of the first rev command) is sent to stderr and 'lorem ipsum' (the output of the second rev command) is sent to stdout. rev reverse lines of a file or files. This use of tee allows testing if a program correctly handles its input without using files that hold the data. Show Sample Output


    2
    rev <<< 'lorem ipsum' | tee /dev/stderr | rev
    penpen · 2009-03-31 13:12:09 7
  • Since the original command (#1873) didn't work on FreeBSD whose stat lacks the "-c" switch, I wrote an alternative that does. This command shows also the fourth digit of octal format permissions which yields the sticky bit information. Show Sample Output


    2
    stat -f '%Sp %p %N' * | rev | sed -E 's/^([^[:space:]]+)[[:space:]]([[:digit:]]{4})[^[:space:]]*[[:space:]]([^[:space:]]+)/\1 \2 \3/' | rev
    vwal · 2009-08-04 08:45:20 3
  • Avoids creating useless directory entries in archive, and sorts files by (roughly) extension, which is likely to group similar files together for better compression. 1%-5% improvement.


    2
    find . \! -type d | rev | sort | rev | tar c --files-from=- --format=ustar | bzip2 --best > a.tar.bz2
    pornel · 2009-12-20 14:04:39 3
  • Just a quick hack to give reasonable filenames to TrueType and OpenType fonts. I'd accumulated a big bunch of bizarrely and inconsistently named font files in my ~/.fonts directory. I wanted to copy some, but not all, of them over to my new machine, but I had no idea what many of them were. This script renames .ttf files based on the name embedded inside the font. It will also work for .otf files, but make sure you change the mv part so it gives them the proper extension. REQUIREMENTS: Bash (for extended pattern globbing), showttf (Debian has it in the fontforge-extras package), GNU grep (for context), and rev (because it's hilarious). BUGS: Well, like I said, this is a quick hack. It grew piece by piece on the command line. I only needed to do this once and spent hardly any time on it, so it's a bit goofy. For example, I find 'rev | cut -f1 | rev' pleasantly amusing --- it seems so clearly wrong, and yet it works to print the last argument. I think flexibility in expressiveness like this is part of the beauty of Unix shell scripting. One-off tasks can be be written quickly, built-up as a person is "thinking aloud" at the command line. That's why Unix is such a huge boost to productivity: it allows each person to think their own way instead of enforcing some "right way". On a tangent: One of the things I wish commandlinefu would show is the command line HISTORY of the person as they developed the script. I think it's that conversation between programmer and computer, as the pipeline is built piece-by-piece, that is the more valuable lesson than any canned script. Show Sample Output


    2
    shopt -s extglob; for f in *.ttf *.TTF; do g=$(showttf "$f" 2>/dev/null | grep -A1 "language=0.*FullName" | tail -1 | rev | cut -f1 | rev); g=${g##+( )}; mv -i "$f" "$g".ttf; done
    hackerb9 · 2010-04-30 09:46:45 6
  • I know there are a lot of random password generators out there, but I wanted something that put out something besides hex. Set count equal to the number of bytes you want. Show Sample Output


    0
    dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev
    TyIzaeL · 2009-02-17 23:36:24 12
  • In case sed and awk are not available you may use this to remove the last character from a string with "rev" and "cut". Show Sample Output


    0
    echo "command lines" | rev | cut -c 2- | rev
    ztank1013 · 2011-09-21 11:27:52 6
  • Good for when you download youtube videos and want the mp3 for your mp3 player.


    0
    for a in $(find . -maxdepth 1 -name "*.mp4" -type f -printf "%f\n" | rev | cut -d '.' -f2- | rev | sort -u); do if [ ! -f "$a.mp3" ]; then avconv -i "$a."* -vn -ab 128 "$a.mp3"; fi done
    adanisch · 2014-06-27 05:13:53 7
  • Find the failed lines, reverse the output because I only see 3 indicators after the IP address, i.e. port, port#, ssh2 (in my file), cut to the 4th field (yes, you could awk '{print $4}'), reverse the output back to normal and then sort -u (for uniq, or sort | uniq). Show Sample Output


    0
    grep Failed auth.log | rev | cut -d\ -f4 | rev | sort -u
    supradave · 2014-08-14 14:57:41 8
  • Gives the DNS listed IP for the host you're on... or replace `hostname` with any other host Show Sample Output


    0
    host `hostname` | rev | cut -d' ' f1 | rev
    shaggyhiggins · 2014-10-01 18:55:05 8
  • Remove everything after the second "rev" to only display the duplicate filenames and their hashes.


    0
    sha1sum * | sort | rev | uniq -df1 | rev | cut -d" " -f3 | xargs rm
    Sparkette · 2015-08-09 20:32:12 9
  • rhyme time mime rhyme lowrez Juarez


    0
    rhyme() { { cat /usr/share/dict/words; printf %s\\n "$1"; } | rev | sort | rev | grep -FxC15 -e "${1?}" | grep -Fxve "$1" | shuf -n1; }
    lowrez · 2016-01-02 03:24:44 13

  • 0
    cat [mysql_dump_file] | grep "Table structure" | cut -c 30- | tr '\n' ' ' | rev | cut -c 2- | rev | tr -d '`'
    Lidorah · 2017-02-08 09:26:01 16
  • You must spezify /where folder and / folder If you have another camera you must experiment with Exif data (after -g and after grep) and mask of your photo files IMG_????.JPG I have do it on Knoppix 6.7.0 You must have installed exiv2. Show Sample Output


    -1
    find / -type f -name IMG_????.JPG -print0 |xargs -0 exiv2 -g Exif.Canon.ModelID '{}' |grep A520 |rev |cut --complement -d " " -f1-40 |rev |xargs -I {} cp --parents {} /where
    fladam · 2012-03-10 03:01:01 3
  • I can't put the last ^2 with seq, so I reverse it to delete the last +N. So for doing sum(N^2) you have to do sum((N+1)^2). Must be a better way. Show Sample Output


    -2
    seq -s^2+ 11 |rev| cut -d'+' -f2- | rev | bc
    rubenmoran · 2011-02-10 08:41:14 7

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

Set laptop display brightness
Run as root. Path may vary depending on laptop model and video card (this was tested on an Acer laptop with ATI HD3200 video). $ cat /proc/acpi/video/VGA/LCD/brightness to discover the possible values for your display.

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

Display Dilbert strip of the day
Requires display. Corrected version thanks to sputnick and eightmillion user.

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

Colorize grep output

move you up one directory quickly
In bash, this turns on auto cd. If a command is just a directory name, it cd's into that directory.

Listen to a song from youtube with youtube-dl and mpv
Explanation Firstly the function checks if user gave it any input, and notifies the user if they failed to do so. If user has inputed a search string, the function will call upon youtube-dl to find url of the audio of the first matching youtube video and play that with mpv. Call function by wrapping search string in quotes: listen-to-yt "sultans of swing" You have to paste the line in your .zshrc and source .zshrc for it to work. Limitations The dependancies are youtube-dl and mpv. this oneliner is stolen from http://www.bashoneliners.com/oneliners/302/

Runs previous command but replacing
Replaces the first instance of 'foo' with 'bar'. To replace all instances of 'foo' with 'bar': !!:gs/foo/bar/

Copy an element from the previous command
You can specify a range via '-'.

Print all git repos from a user (only curl and grep)


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: