Commands using unset (14)

  • this will cause any commands that you have executed in the current shell session to not be written in your bash_history file upon logout


    18
    unset HISTFILE
    grokskookum · 2009-05-20 14:46:18 19
  • Unset TMOUT or set it to 0 in order to prevent shell autologout. TMOUT is the number of seconds after which the present shell will be killed if it has been idle for that long.


    7
    unset TMOUT
    sharfah · 2009-05-20 14:57:50 12
  • Unsetting HISTFILE avoid getting current session history list saved.


    6
    unset HISTFILE
    Delian · 2010-11-15 09:16:11 7
  • works on all unices. Show Sample Output


    4
    function nowrap { export COLS=`tput cols` ; cut -c-$COLS ; unset COLS ; }
    mobidyc · 2009-09-11 15:07:00 13
  • Simply sourcing .bashrc does not function correctly when you edit it and change an alias for a function or the other way round with the *same name*. I therefor use this function. Prior to re-sourcing .bashrc it unsets all aliases and functions.


    4
    bashrc-reload() { builtin unalias -a; builtin unset -f $(builtin declare -F | sed 's/^.*declare[[:blank:]]\+-f[[:blank:]]\+//'); . ~/.bashrc; }
    Xk2c · 2014-03-02 14:24:18 9
  • First argument: string to put a box around. Second argument: character to use for box (default is '=') Same as command #4962, cleaned up, shortened, and more efficient. Now a ' * ' can be used as the box character, and the variables get unset so they don't mess with anything else you might have. They marked c++ as a function for this command, but I'm not sure why. Must be a bug. Show Sample Output


    2
    box(){ c=${2-=}; l=$c$c${1//?/$c}$c$c; echo -e "$l\n$c $1 $c\n$l"; unset c l;}
    mightybs · 2010-02-26 17:14:52 3
  • pushd and popd are your friends, but sometimes they're just incompatible with the way one works... Two shell functions: bm bookmarkname - "bookmarks" the current directory, just 'cd $BMbookmarkname' to return to it. forget bookmarkname - unsets the 'bookmarkname' variable. It isn't mandatory, they cease to exist when the session ends. Show Sample Output


    2
    bm() { export BM${1?"bookmark name missing"}="$PWD" ; }; forget() { unset BM${1?"bookmark name missing"} ; }
    unefunge · 2010-11-19 12:15:11 9

  • 1
    MYSQL="mysql -h HOST -u USERNAME -pPASSWORD -D DB_NAME" ; $MYSQL -BNe "show tables" | awk '{print "set foreign_key_checks=0; drop table `" $1 "`;"}' | $MYSQL unset MYSQL
    gadget00 · 2009-12-01 17:42:38 7
  • make, find and a lot of other programs can take a lot of time. And can do not. Supppose you write a long, complicated command and wonder if it will be done in 3 seconds or 20 minutes. Just add "R" (without quotes) suffix to it and you can do other things: zsh will inform you when you can see the results. You can replace zenity with other X Window dialogs program.


    1
    alias -g R=' &; jobs | tail -1 | read A0 A1 A2 cmd; echo "running $cmd"; fg "$cmd"; zenity --info --text "$cmd done"; unset A0 A1 A2 cmd'
    pipeliner · 2010-12-13 17:44:36 2

  • 1
    echo 'set term dumb; unset border; unset xtics; unset ytics; p "< seq 10 | shuf" u 1:(rand(0)) w l notitle' | gnuplot
    kev · 2011-11-30 02:08:53 4

  • 1
    unset HISTFILE
    aysadk · 2017-09-01 09:12:11 19
  • unsets variables used by the one-liner sets up the IFS bash variable to not be affected by whitespace and disables extra glob expansion uses read to slurp the results of the find command into an array selects an element of the array at random to be passed as an argument to mplayer


    0
    unset files i; set -f; O=$IFS; while IFS= read -r -d $'\0' files[i++]; do :; done < <(find . -name '*.avi' -print0) && IFS=$O; set +f && echo "Running: mplayer \"${files[ $(( $RANDOM % ${#files[@]} )) ]}\""
    DEinspanjer · 2009-02-18 16:53:57 5
  • If I type 'man something', I want it to find the manpage in the same order as my PATH. You can add something like this to your .bashrc # # Add my MacPorts, my personal utilities and my company utilities to my PATH. export PATH=$PATH:/opt/local/bin:$HOME/bin:/our_company_utils/bin/ # Now set the manpath based on the PATH, after man(1) parses man.conf # - No need to modify man.conf or manually modify MANPATH_MAP # - Works on Linux, FreeBSD & Darwin, unlike /etc/manpaths.d/ # Must unset MANPATH first. MANPATH is set on some systems automatically (Mac), # which causes manpath to ignore the values of PATH like /opt/local/bin (MacPorts). # Also MANPATH may be deprecated. See "SEARCH PATH FOR MANUAL PAGES" in man(1) unset MANPATH # manpath acts differently on Solaris, FreeBSD, MacOSX & GNU. This works everywhere. manpath >/dev/null # Note that MacOSX, FreeBSD & Linux have fancier ways to do some of this. (e.g. 'man --path' or 'man -q'), but this command is more universal and should work everywhere. Show Sample Output


    0
    unset MANPATH; manpath >/dev/null
    StefanLasiewski · 2010-07-02 19:45:27 3
  • The given file may contain any kind of characters. This is compatible for most simple mathematical operation. For the first number found, it will be replaced by the result of a factor operation of 1000. To change the filename or multiplactor or number regular expression, change the first fixed values. Show Sample Output


    0
    n=1000;f="test.csv";r='([0-9]+.{0,1}[0-9]*)';echo -n "" > new_${f};cat $f | while read l;do val=`echo $l | egrep -o $r` ; if [ ! -z $val ];then newval=`echo $val \* $n | bc -l`;l=`echo $l | sed "s/$val/$newval/"`;fi;echo $l >> new_${f};unset val;done
    s333 · 2017-04-26 18:04:07 19

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

force unsupported i386 commands to work on amd64
The above was done using the i386 flashplayer plugin, and was installed on a AMD64 machine running an AMD64 kernel and AMD64 programs. the resulting plugin install ultimately didn't work for swiftfox (but worked for iceweasel) without also covering it with a nspluginwrapper which took a bit of fenangaling to get to work (lots of apt-getting) but it is a nice feature to be able to trick installers that think you need i386 into running on a amd64, or at least attempting to run on amd64. Enjoy

Gets the english pronunciation of a phrase
Usage examples: say hello say "hello world" say hello+world

Generat a Random MAC address
Generate a random MAC address with capital letters

Extract tarball from internet without local saving

Check whether laptop is running on battery or cable
The original proc file doesn't exist on my system.

Install pip with Proxy
Installs pip packages defining a proxy

Send a local file via email
This just reads in a local file and sends it via email. Works with text or binary. *Requires* local mail server.

dont execute command just add it to history as a comment, handy if your command is not "complete" yet

list files recursively by size

Get the IP address
gives u each configured IP in a seperate line.


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: