Commands tagged history search (6)

  • userful for direct copy & paste command for doumenation or next using Show Sample Output


    6
    history -w /dev/stdout
    aysadk · 2022-10-29 15:17:37 898
  • This command disable sending of start/stop characters. It's useful when you want to use incremental reverse history search forward shortcut (Ctrl+s). To enable again, type: stty -ixoff


    1
    stty -ixon
    ricardofunke · 2012-05-28 19:04:19 4
  • worse alternative to ctrl+r: grep the history removing duplicates without sorting (case insensitive search). Show Sample Output


    1
    function memo() { awk '! seen[$0]++' <<< $(grep -i "$@" ~/.bash_history ); }
    mikhail · 2019-04-04 00:54:43 37

  • 0
    function hgr() { grep --color -i "${1}" ~/.bash_history | sed -e 's/^ *//g' -e 's/ *$//g' | sort | uniq; }
    doge · 2013-11-27 16:54:02 8
  • Appends 4 configuration lines to your ~/.inputrc which allow you to seach history taking into account the characters you have typed so far. It is taken straight form https://help.ubuntu.com/community/UsingTheTerminal Go there for a complete description (grep for "Incremental history searching"). Not sure about the limits of this (which OS's/terminals), but probably anything unix/linux like will do. Changed my life :) Show Sample Output


    0
    echo '\n"\e[A": history-search-backward\n"\e[B": history-search-forward\n"\e[C": forward-char\n"\e[D": backward-char\n' >> ~/.inputrc
    temach · 2015-01-15 09:47:49 9
  • I seem to do this compulsively every time I change directories, sometimes even when I don't, even if I know exactly what I need to do. (Don't worry, the sample output is just an exaggeration. :) Show Sample Output


    0
    grep -cx ls ~/.bash_history
    Sparkette · 2016-09-14 17:06:59 17

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

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Display EPOCH time in human readable format using AWK.

Sort a character string
using perl

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

BASH: Print shell variable into AWK

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

Print a cron formatted time for 2 minutes in the future (for crontab testing)
Another function to stick into your .bashrc This spits out the time two minutes in the future, but already formatted for pasting into your crontab file for testing without any thought required on your part. Frequently things don't work the way you expect inside a crontab job, and you probably want to find out now that your $PATH is completely different inside of cron or other global variables aren't defined. So this will generate a date you can use for testing now, and then later you can change it to run at 5:37 am on a Sunday evening.

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

Monitor memory without top or htop
It repeats a command, such as free, every five seconds and highlights the differences

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.


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: