Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 445 Bytes

define-functions.md

File metadata and controls

21 lines (17 loc) · 445 Bytes

#Defining customized functions

To define functions the ~/.bashrc file hase to be modified. Example:

[...]
mygrants()
{
  mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
    'SHOW GRANTS FOR \'', user, '\'@\'', host, '\';'
    ) AS query FROM mysql.user" | \
  mysql $@ | \
  sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
}

export mygrants
[...]

The function can be used after the session has been restarted.