findmnt – find all the mounts and their source

If you are looking for the source of a mount and the various options used in the mount, then the quickest way to get that is ::

findmnt

By default, with no parameters, it lists all the mounts in a tree like view and all the options used to mount the path. It also lists the source of the mount.

By default again, it uses some capabilities of the terminal to show the tree which you can disable with the option “-a”.

You can check the man page for more information on this command, it has some pretty good examples as well.

And just in case, you are unable to find the package (util-linux) containing the command:

sudo yum install util-linux
 
Enhanced by Zemanta

GREP_COLORS – change the colors in the GREP output.

Today we will look at the variable GREP_COLORS. This variable determines the colour that is used with the grep command. You can look at the man page of the grep command to see what the various options mean. Here is the excerpt from the man command:

    GREP_COLORS
              Specifies the colors and other attributes used to highlight various  parts  of  the
              output.   Its  value  is  a  colon-separated  list of capabilities that defaults to
              ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36  with  the  rv  and  ne   boolean
              capabilities omitted (i.e., false).  Supported capabilities are as follows.

              sl=    SGR  substring  for  whole  selected lines (i.e., matching lines when the -v
                     command-line option is omitted, or non-matching lines when -v is specified).
                     If however the boolean rv capability and the -v command-line option are both
                     specified, it applies to context matching lines  instead.   The  default  is
                     empty (i.e., the terminal's default color pair).

              cx=    SGR  substring for whole context lines (i.e., non-matching lines when the -v
                     command-line option is omitted, or matching lines when -v is specified).  If
                     however  the  boolean  rv capability and the -v command-line option are both
                     specified, it applies to selected non-matching lines instead.   The  default
                     is empty (i.e., the terminal's default color pair).

              rv     Boolean  value  that  reverses  (swaps)  the  meanings  of  the  sl= and cx=
                     capabilities when the -v command-line option is specified.  The  default  is
                     false (i.e., the capability is omitted).

              mt=01;31
                     SGR  substring  for  matching  non-empty  text in any matching line (i.e., a
                     selected line when the -v command-line option is omitted, or a context  line
                     when  -v  is specified).  Setting this is equivalent to setting both ms= and
                     mc= at once to the same value.  The default is a bold  red  text  foreground
                     over the current line background.

              ms=01;31
                     SGR substring for matching non-empty text in a selected line.  (This is only
                     used when the -v command-line option is omitted.)  The effect of the sl= (or
                     cx=  if  rv) capability remains active when this kicks in.  The default is a
                     bold red text foreground over the current line background.

              mc=01;31
                     SGR substring for matching non-empty text in a context line.  (This is  only
                     used  when  the -v command-line option is specified.)  The effect of the cx=
                     (or sl= if rv) capability remains active when this kicks in.  The default is
                     a bold red text foreground over the current line background.

              fn=35  SGR  substring  for file names prefixing any content line.  The default is a
                     magenta text foreground over the terminal's default background.

              ln=32  SGR substring for line numbers prefixing any content line.  The default is a
                     green text foreground over the terminal's default background.

              bn=32  SGR substring for byte offsets prefixing any content line.  The default is a
                     green text foreground over the terminal's default background.

              se=36  SGR substring for separators that are inserted between selected line  fields
                     (:),  between context line fields, (-), and between groups of adjacent lines
                     when nonzero context  is  specified  (--).   The  default  is  a  cyan  text
                     foreground over the terminal's default background.

              ne     Boolean  value that prevents clearing to the end of line using Erase in Line
                     (EL) to Right (\33[K) each time a colorized item ends.  This  is  needed  on
                     terminals on which EL is not supported.  It is otherwise useful on terminals
                     for which the back_color_erase (bce) boolean terminfo  capability  does  not
                     apply,  when  the  chosen  highlight colors do not affect the background, or
                     when EL is too slow or causes too much flicker.  The default is false (i.e.,
                     the capability is omitted).

Now time for some examples:

1) With GREP_OPTIONS set to “”

1
export GREP_OPTIONS=

 

grep color options
grep color options

2) with the following set:

1
export GREP_COLORS="fn=34:mc=01;30:ms=33:sl=21:cx=31"

 

grep color options
grep color options

3) and just the colour for filename and match:

1
export GREP_COLORS="mc=00;36:ms=31:mt=01;38"

 

grep color options
grep color options

4) Slightly lighter colour:

1
export GREP_COLORS="mc=00;36:ms=31:mt=01;33"

 

grep color options
grep color options

5) Default colour for line numbers:

 

grep color options
grep color options

6) Line number colour:

1
export GREP_COLORS="mc=00;36:ms=31:mt=01;38:ln=31"

 

grep color options
grep color options

Hope you will put some colour to grep.

Enhanced by Zemanta

Print all environment variables, including hidden ones

Print all environment variables, including hidden ones

1
for _a in {A..Z} {a..z};do _z=${!${_a}*};for _i in `eval echo "${_z}"`;do echo -e "$_i: ${!_i}";done;done|cat -Tsv

This uses some tricks I found while reading the bash man page to enumerate and display all the current environment variables, including those not listed by the ‘env‘ command which according to the bash docs are more for internal use by BASH. The main trick is the way bash will list all environment variable names when performing expansion on ${!A*}. Then the eval builtin makes it work in a loop.

I created a function for this and use it instead of env. (by aliasing env).

This is the function that given any parameters lists the variables that start with it. So ‘aae B’ would list all env variables starting wit B. And ‘aae {A..Z} {a..z}’ would list all variables starting with any letter of the alphabet. And ‘aae TERM’ would list all variables starting with TERM.

1
aae(){ local __a __i __z;for __a in "$@";do __z=${!${__a}*};for __i in `eval echo "${__z}"`;do echo -e "$__i: ${!__i}";done;done; }

And my printenv replacement is:

1
alias env='aae {A..Z} {a..z} "_"|sort|cat -v 2>&1 | sed "s/\^\[/\ ?33/g"'

From: http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html

* View this command to comment, vote or add to favourites * View all commands by AskApache

commandlinefu.com

by David Winterbottom (codeinthehole.com)

URL: http://www.commandlinefu.com/commands/view/6899/print-all-environment-variables-including-hidden-ones

Enhanced by Zemanta