Microsoft
Software
Hardware
Network
Question : Quote string within bash
Hello,
I have the following bash code fragment:
x=0
for i in $(locate $1)
do
dnames[$x]=$(dirname $i)
let x=$x+1
done
Which assigns the output of a locate command into the array dnames one line at a time. It works fine except when the path being returned from locate contains spaces in it, which appears to cause bash to break the input line at the space and put the line in two array locations.
Is there a way to quote the input to dnames to prevent spaces from being interpreted?
Thanks!
Answer : Quote string within bash
IFS='
'
x=0
for i in $(locate $1)
do
dnames[$x]=$(dirname $i)
let x=$x+1
done
or
IFS='
'
dnames=($(locate $1))
Random Solutions
NSLOOKUP Fails, Pings are successful.
Memory Alarm After SVmotion
i have a VBA code work with windows XP but not with Vista?
Autodiscovery workaround for Free/Busy and OOF status in Exchange Server 2k7 + Outlook 2007
How to check for null value in trigger?
Stopped and Zombie processes
Change SQL cluster account permission
Using a LIST and LOOP within a batch file
NTBACKUP ISSUE
workforce 600 OSX browse to memory card