CSH

Foreach loop in CSH

CSH foreach loop (Note: Can be used as an advanced alternative to pipe)

foreach list (`ls *.txt`)

echo $list

end

Special characters in CSH variables

CSH tries to use wildcards when special characters are present in the variables like (*, ., etc). Using a variable called "noglob" we can instruct CSH to don't use content of registers as wildcards

set noglob=""

set var="foo.*bar"

echo $var

unset noglob

Colored terminal output (tcsh)

To set colored output on terminal special escape characters needs to be used.

e.g.

echo "\e[1;31m This is colored red \e[1;32m and now changed to green \e[0m"

set prompt="${blue}%~ >>${end} "

COLOR CODE:

Black 0;30 Dark Gray 1;30

Blue 0;34 Light Blue 1;34

Green 0;32 Light Green 1;32

Cyan 0;36 Light Cyan 1;36

Red 0;31 Light Red 1;31

Purple 0;35 Light Purple 1;35

Brown 0;33 Yellow 1;33

Light Gray 0;37 White 1;37

Command line calculator

"bc" is a command line utility which is used as a calculator.


e.g.:

bc

1+1

2

CTRL+D


It can also be used in pipe as follows,

echo 'ibase=16; FF' | bc


A good alias will be,

alias hex2dec "echo 'ibase=16; \!:*' | bc"