I am an infrequent user of UNIX, I'm sure this will be fairly trivial for any regular user so I appologize for that. I have the following code: for file in /home/sub1/samples/aaa*/*_novoalign.bam      do           samtools depth -r chr9:218026635-21994999 *_novoalign.bam < $file > /home/sub2/sub3/${file}.out       doneI was hoping the output would be sent to a file in sub2/sub3/ with its name like the input folder. It says 'no file or directory'. I would ideally like to send it here with the '_novoalign.bam' removed and a new ending eg '_output.txt' added. Any tips?p.s. I don't have permission to write to the directory in which the input file is found.
Unix how to loop through directories, send output to another directory with base name of input file
shell script;io redirection;filenames