I want a script to execute the command: 
ls -alst "dir with spaces" 


The script looks like this : 
#! /bin/bash 

PARAMS_FOR_LS="-alst \"dir with spaces\"" 

echo $PARAMS_FOR_LS 

ls $PARAMS_FOR_LS 



when I execute the script: 
bash -x script.sh 


I get: 
+ PARAMS_FOR_LS='-alst "dir with spaces"' 
+ echo -alst '"dir' with 'spaces"' 
-alst "dir with spaces" 
+ ls -alst '"dir' with 'spaces"' 
ls: cannot access "dir: No such file or directory 
ls: cannot access with: No such file or directory 
ls: cannot access spaces": No such file or directory 

why the extra quotes ?? 


Reply via email to