Linux commands

Вывод текста в цвете

echo -e "\e[1;31m This is red text \e[0m"

reset=, black=30, red=31,green=32, yellow=33, blue=34, magenta=35, cyan=36, and white=37.

$ cat /proc/12501/environ | tr ‘\0’ ‘\n’ HTTP_PROXY=http://192.168.0.2:3128 export HTTP_PROXY export PATH="$PATH:/home/user/bin"

Длина строки

$ var=12345678901234567890 $ echo ${#var} 20

Проверка суперпользователя

if [ $UID -ne 0 ]; then echo Non root user. Please run as root. else echo "Root user" fi

Перенаправление

cmd 2>&1 output.txt $ cmd 2>stderr.txt 1>stdout.txt #!/bin/bash cat <<EOF>log.txt LOG FILE HEADER This is a test log file Function: System statistics EOF

Print Friendly, PDF & Email