Friday, June 24, 2011

AWK and Java CLASSPATH

From http://unix-simple.blogspot.com/2008/12/dynamically-building-java-classpaths.html

for line in $java_dir/*.jar
do
  CLASSPATH="$CLASSPATH:$line"
done

Lets put AWK to iterate:

CLASSPATH=$CLASSPATH:$(ls *.jar | awk 'BEGIN { ORS = ":" } { print }')

Maybe a shellish way of do it:

CLASSPATH=$CLASSPATH:`echo *.jar | sed 's/ /:/g'`

No comments: