Reputation: 137
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
?
Upvotes: 2
Views: 98
Reputation: 1333
:
is a separator for the CLASSPATH.
Your script basically:
/home/dir1/dir2/dir3
../lib/*
to FILES
.
(the current directory) and ../conf
to CLASSPATH
(separated with the :
)FILES
sets the CLASSPATH
to itself (to keep the old value) and append the path of the found file (again separated with the :
)Upvotes: 6
Reputation: 172894
:
is separator.
So what they're doing is get all the file in the directory ../lib
, and append them all to CLASSPATH
by for loop.
Upvotes: 1