≡ Menu

bash for

Bash For Loop Spaces

How do I use bash for loop with spaces in a file name on Unix or Linux operating system? The following code fails with errors:

#!/bin/bash
files=$(ls *.txt)
dest="/nas/server/dest"
for f in $files
do
cp "$f" $dest
done

How do I fix this problem on bash shell?
[click to continue…]

Linux bash for loop

Q. How do I use bash for loop under Linux operating systems?
[click to continue…]