Link to home
Start Free TrialLog in
Avatar of dplinnane
dplinnaneFlag for United States of America

asked on

list directory with spaces shell script

or file in `ls`; do echo "cp -R $dir  ./dir2/";  done
 
This works great except directories with spaces do not work as expected.  For example directory name  sales and returns

echoes
cp -R /dir1/sales  /dir2/
cp -R/dir1/and  /dir2/
cp -R /dir1/returns  /dir2/

I should get
cp -R /dir1/sales and returns  /dir2/

How do I stop directory names with spaces from being split?

I'll close the question after this (-: thanks all.
SOLUTION
Avatar of vvk
vvk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial