I have been trying to alter an old Shell Script for my project. I have done some researching but the usage of :
in shell script but is quite unclear to me.
#!/bin/bash
cd /home/dir1/dir2/dir3
FILES=../lib/*
CLASSPATH=.:../conf/
for f in $FILES
do
CLASSPATH=$CLASSPATH:$f
done
echo $CLASSPATH
What are they trying to do here, is it looking for same named files in both directories and assigning them to CLASSPATH
?
:
, i.e. the paths inCLASSPATH
are separated by a:
– arco444 Dec 2 '15 at 12:14CLASSPATH=.:/home/dir1/dir2/conf$(printf ":%s" /home/dir1/dir2/lib/*)
– tripleee Dec 2 '15 at 12:38printf
or not an array here would be much safer. That said with an array one could also use$(IFS=:; echo "${arr[*]}")
. – Etan Reisner Dec 2 '15 at 13:41