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
Trying to edit fRSMemberReferenceBL with ADSI Edit and get error attribute owned by system
NTLDR is missing on XP
Default Public Role Permissions
Windows Server 2003 - SNTP and NTP settings
How can I safely delete extra user profile folders in Documents and Settings?
Relaying denied
[Servlet Error]-[LocalTransaction rolled-back due to setRollbackOnly]: com.ibm.ws.LocalTransactio<wbr />n.Rolledba<wbr />ckExceptio<wbr />n
Will changing the "Default location for PST files" in the Outlook GPO effect .OST files?
Recommendations for Internet-based Remote Desktop Solutions
0x800CCC78 - error sending email