line="touch : touch : test.txt"
IFS=':' read scr cmd <<< "$line"
echo $scr
echo $cmd
output:
touch
touch : test.txt
line="touch : touch : test.txt"
IFS=':'
read scr cmd <<< "$line"
echo $scr
echo $cmd
output:
touch
touch test.txt
I don't understand how the second syntax makes read remove the ':' . Any ideas?
readdoesn't remove it - echoing the unquoted$cmdwithIFSset to:does – steeldriver Jun 09 '23 at 12:16readis not a special built-in, so settingIFSfor read will not make it persist afterreadreturns, so the lack of quoting doesn't affect the commands after it the same way as in the second example. – muru Jun 09 '23 at 12:25