0

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.

Benjamin
  • 11,560
  • 13
  • 70
  • 119

1 Answers1

1

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.

Kevin Grant
  • 5,363
  • 1
  • 21
  • 24
  • You can use normal spaces and tabs to indent. I suspect that you accidentally typed the non-breaking version (which is a different code that isn't recognized as whitespace by the shell). – Kevin Grant Jul 10 '12 at 00:08
  • I probably used regular spaces in Rich Text which got converted to the wrong space in plain text. Thanks... – Benjamin Jul 10 '12 at 00:09