ls -lhAXF --group-directories-first "$@" | awk '
BEGIN {
FPAT = "([[:space:]]*[^[:space:]]+)";
} {
$1 = "\033[1m" "\033[31m" $1 "\033[0m";
$2 = "\033[1m" "\033[32m" $2 "\033[0m";
$3 = "\033[1m" "\033[33m" $3 "\033[0m";
$4 = "\033[34m" $4 "\033[0m";
$5 = "\033[1m" "\033[35m" $5 "\033[0m";
$6 = "\033[1m" "\033[36m" $6 "\033[0m";
$7 = "\033[1m" "\033[37m" $7 "\033[0m";
$8 = "\033[1m" "\033[33m" $8 "\033[0m";
print
}'
what is the correct syntax to achieve the following:
- color normal directory to red
- color hidden directory to blue
- color regular file to green
what i know:
- match normal directory with regex like any word ending with '/' inside column $9
- match hidden directory with regex like any word starting with '.' inside column $9
- match regular file with regex like the rest of line that doesn't match ending with '/' and doesn't match starting with '.'
- i know something like:
awk '$9 ~ /something/'
to match the right column
but where to put the syntax, and what is the syntax look like?
i want to colorize the result of the regex after it matches using escape code like "\033[32m"