Verify all the paths in the PATH directory

Here is the command to test that all the directories in your path actually exist.

(IFS=:;for p in $PATH; do test -d $p || echo $p; done)

And the explanation :

Set the IFS to \”:\”

now we loop through the PATH variable

and test all the directories with \”test -d\”

Here is another version without IFS:

for i in ${PATH//:/ };do test  -d $i || echo $i;done


and next one without the test command:

for i in ${PATH//:/ };do [  -d $i ] || echo $i;done

\"Reblog

colors in bash — script to display all the possible colors.

If you wanted to have colors in the bash output (including the colors in PS1-4), don\’t you keep wondering how the color code would look on the terminal. So, I wrote this small script to show the complete color codes. This is how the output would look:

\"Bash

And here is the script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash -
#===============================================================================
#
#          FILE:  colors.sh
#
#         USAGE:  ./colors.sh
#
#   DESCRIPTION:  Bash colors
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR:  Amit Agarwal (AKA), [email protected]
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  09/21/2009 06:12:07 PM IST
#      REVISION:  ---
#===============================================================================

for c in `seq 0 255`;
do
t=5;
[[ $c -lt 108 ]]&&t=0;
for i in `seq $t 5`;
do
#Display the codes also for easier lookup in terminal
<!--loginview start-->echo $i;${c}<!--loginview end-->
echo -e "<a class="zem_slink" title="Path (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Path_%28computing%29">\\</a>\e[0;48;$i;${c}m|| $i:$c `seq -s+0 $(($COLUMNS/2))|tr -d \'[0-9]\'`\\e[0m";
done;
done

# setup_colors - Adds colors to array CC for global use
# 30 - Black, 31 - Red, 32 - Green, 33 - Yellow, 34 - Blue,
# 35 - Magenta, 36 - Blue/Green, 37 - White,
# 30/42 - Black on Green \'30\\;42\'
<!--loginview start-->function setup_colors(){
declare -a CC;
for i in `seq 0 7`;
do
ii=$(($i+7));
CC[$i]="\\033[1;3${i}m";
CC[$ii]="\\033[0;3${i}m";
done;
CC[15]="\\033[30;42m";
R=$\'\\033[0;00m\';
X=$\'\\033[1;37m\';
export R X;
}
function display_colors(){
for i in $(seq 0 $((${#CC[@]} - 1))); do echo -e "${CC[$i]}[$i]\\n$R"; done
}
\"Reblog
Enhanced by Zemanta