Separate string based on delimiter

Hi,

for fd in $(grep "/tmp/" hello.properties)

The grep gives me the below output:

deploydir=/tmp/app1/dfol
prodir= /tmp/hello/prop
......

Now i want to store /tmp/app1/dfol then /tmp/hello/prop in a variable so that i can check if those folders files exists or not.

The delimiter would be "="

Can you help me with this ?

$ for fd in $(grep "/tmp/" hello.properties | cut -d'=' -f2-); do echo $fd; done
1 Like

Thank you

Or assign to an array like (in bash)

Arr=( $(grep -o "/tmp/.*" hello.properties ))

A pure bash/ksh solution:

IFS=$'=\n'
while read type dir
do
    [[ $dir = */tmp/* ]] && echo $type $dir
done < hello.properties