PROMPT_COMMAND
$ PROMPT_COMMAND='echo -n "writing the prompt at " && date'
HISTTIMEFORMAT
history
in the console, you will receive a list of commands previously executed under your account. $ HISTTIMEFORMAT='I ran this at: %d/%m/%y %T '
1871 I ran this at: 01/05/19 13:38:07 cat /etc/resolv.conf 1872 I ran this at: 01/05/19 13:38:19 curl bbc.co.uk 1873 I ran this at: 01/05/19 13:38:41 sudo vi /etc/resolv.conf 1874 I ran this at: 01/05/19 13:39:18 curl -vvv bbc.co.uk 1876 I ran this at: 01/05/19 13:39:25 sudo su -
CDPATH
PATH
, the variable CDPATH
is a list of paths separated by a colon. When you run the cd
with a relative path (that is, without a slash at the beginning), by default, the shell looks for the appropriate names in your local folder. CDPATH
will search the paths you gave for the directory where you want to go.CDPATH
like this: $ CDPATH=/:/lib
$ cd /home $ cd tmp
/tmp
no matter where you are..
) Folder in the list, you will not be able to create any other tmp
folder and go to it as usual: $ cd /home $ mkdir tmp $ cd tmp $ pwd /tmp
PATH
variable ... but you have to do it in the PATH variable, because you can be fooled by running a fake command from some downloaded code. CDPATH=.:/space:/etc:/var/lib:/usr/share:/opt
SHLVL
exit
will take you from the current bash shell to another “parent” shell or just close the console window completely? $ echo $SHLVL 1
$ bash $ echo $SHLVL 2
LINENO
LINENO
variable is useful for analyzing the current state and debugging, which reports the number of commands executed in the session to date: $ bash $ echo $LINENO 1 $ echo $LINENO 2
echo DEBUG:$LINENO
, you can quickly determine where in the script you are (or not).REPLY
$ read input echo do something with $input
$ read echo do something with $REPLY
TMOUT
sleep 1 && exit
: $ TMOUT=1
Source: https://habr.com/ru/post/451492/
All Articles