I'm trying to use filenames loaded from a directory.
It works fine but once the filename has whitespaces it doesn't work.
I'll demonstrate:
Assume your in folder scriptExample
with three filename dummy file one
, dummy file two
, dummy file three
.
My scripts performs simple cat
command for each file
#!/bin/bash
for i in *
do
cat $i
done
However when you run this you get:
cat: dummy: No such file or directory
cat: file: No such file or directory
cat: one: No such file or directory
cat: dummy: No such file or directory
cat: file: No such file or directory
cat: three: No such file or directory
cat: dummy: No such file or directory
cat: file: No such file or directory
cat: two: No such file or directory
#!/bin/bash
for i in *
do
cat $i
done