Hello I would like to ask how can I get unique string from variable.
while read -r line
do
route=$(echo $line | awk -F'[:]' '{print $2}') #get path from log file
if [ "`dirname "$route"`" == "`xrealpath "$PWD"`" ]; then #compare path from log file with $PWD
name=$(echo $line | awk -F'[:]' '{print $1}') #take name from 1st column in log file
fi
if ! [ "$name" == "$help_name" ]; then
echo $name
help_name=$name
pom=$pom:$name
fi
done < $WEDI_RC
Sample logfile:
proj.sh:/Users/Tom/Documents/proj.sh:2015-03-21:1
proj1.sh:/Users/Tom/Documents/proj.sh:2015-03-21:1
proj.sh:/Users/Tom/Documents/proj.sh:2015-03-21:2
proj1.sh:/Users/Tom/Documents/proj.sh:2015-03-21:2
proj.sh:/Users/Tom/Documents/proj.sh:2015-03-21:3
proj1.sh:/Users/Tom/Documents/proj.sh:2015-03-21:3
How can I echo each unique just one time?
My output now looks something like this:
proj.sh
proj1.sh
proj.sh
proj1.sh
proj.sh
:proj.sh:proj1.sh:proj.sh:proj1.sh:proj.
Expecting output:
proj.sh
proj1.sh
I don't know how much files can be readed in while cycle. We cannot use any temporary files Thank you