Bash tips

How to convert string to array of strings

#1st declare our separator
IFS=";"
#define our string we want to split
NAMES="Linus Benedict Torvalds;James Bond;Franta Novak"
#try this one:
AR_N=($NAMES)
#OR this one (if previous not working):
read -a AR_N <<<"$NAMES"
#remove our previously defined separator
unset IFS

variable AR_N not contains our separated strings, 1st item in array is AR_N[0]


Convert small letters to big ones

echo abcd | tr [:lower:] [:upper:]

Convert hexadecimal number to decimal

echo "ibase=16; `echo 2f194| tr [:lower:] [:upper:]`" | bc

 

VIM editor

vim editor is very popular among linux/unix admins. On of cool feature is syntax highlighting. Did u know what you can disable this highlighting or change color scheme ?

To enable/disable syntax highlighting  type:

:syntax on/off

To change color cheme in vim :

:colo SCHEME

where SCHEME can be eg. delek, desert, morning

To make this options permanent just create/modify file "~/.vimrc" eg

colo desert
syntax on

Leave a Reply

Your email address will not be published. Required fields are marked *

Write numbers u see, eg. 365 *