I am trying to cat 4 files one directory down to a new file, also one directory down:
cat ./dira/file.txt ./dirb/file.txt ./dirc/file.txt ./dird/file.txt > ./dire/file.txt
I can get this to work from the Terminal, but not in the following:
for i in `ls -d prefix*`
do
cd $i
pwd
cat ./dira/file.txt ./dirb/file.txt ./dirc/file.txt ./dird/file.txt > ./dire/file.txt
done
where pwd prints the correct directory. I get the error: -bash: : command not found.
There must be a non-breaking space at the start of one of the lines in your file (easily done by typing option-space by accident during editing). The shell would consider that to be a word and try to run the non-breaking space as a command; this produces the “bash: : command not found” error that you see.