1829589 Members
8329 Online
109992 Solutions
New Discussion

Script help needed.

 
SOLVED
Go to solution
Sebastien Masson
Valued Contributor

Script help needed.

I have a shell variable with this:

$tmpdir="/opt/omni/newconfig/var/opt/omni/tmp /opt/hpnp/tmp /opt/bb18b3/tmp /opt/foglight/tmp /tmp /var/opt/pd/tmp /var/opt/omni.bak/tmp /var/tmp /var/spool/cron/tmp /var/dt/tmp"

I use this command to put a /* at the end of each path:

# echo $tmpdir | sed -e 's/ /\/\* /g' | sed -e 's/\(.*\)$/\1\/\*/'

Now if I:

a=$(echo $tmpdir | sed -e 's/ /\/\* /g' | sed -e 's/\(.*\)$/\1\/\*/');

The output of $a have all the file in each path. How do I prevent path filename resolving in inline substitution
4 REPLIES 4
Robin Wakefield
Honored Contributor
Solution

Re: Script help needed.

Hi Sebastien,

Issue "set -f" before you issue the command, to disable filename generation.

Switch it back on with "set +f"

Rgds, Robin.
harry d brown jr
Honored Contributor

Re: Script help needed.

how about putting a double backslash in front of \*, like \\\*


live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: Script help needed.

Robin,

That's why I love this forum. I just learned something new :-))

thanks!!!


live free or die
harry
Live Free or Die
Deepak Extross
Honored Contributor

Re: Script help needed.

This is nowhere near as elegant as Robin's reply, but I remember getting around this problem by
#mkdir -p /tmp/temp_dir111
#cd -p /tmp/temp_dir111

(there are no files here, so nothing to expand)
#cd -
#rm -rf /tmp/temp_dir111

if only i was into this forum back then...