Reputation: 11
When using the concatenated syntax to input a list of files into a program, the first file seems to not error out but then the rest of the files after the first get the error "Permission denied". It doesn't matter what the first file is, I could set the last file of the list as the first input and it gets accepted but everything after this gets the "permission denied" error.
Any ideas?
I have checked folder permissions and set chmod for this folder to 755 but the problem persists.
RAW_DIR=/gpfs/ts0/projects/Research/sequencing/H0243/01_raw_reads/
FILES=`ls -m ${RAW_DIR}3013_12_r1.fq.gz|${RAW_DIR}3013_12_r2.fq.gz|${RAW_DIR}3013_14_r1.fq.gz|${RAW_DIR}3013_14_r2.fq.gz|${RAW_DIR}3013_15_r1.fq.gz|${RAW_DIR}3013_15_r2.fq.gz|${RAW_DIR}3013_16_r1.fq.gz|${RAW_DIR}3013_16_r2.fq.gz|${RAW_DIR}3013_31_r1.fq.gz|${RAW_DIR}3013_31_r2.fq.gz|${RAW_DIR}3013_33_r1.fq.gz|${RAW_DIR}3013_33_r2.fq.gz|${RAW_DIR}3013_34_r1.fq.gz|${RAW_DIR}3013_34_r2.fq.gz|${RAW_DIR}3013_36_r1.fq.gz|${RAW_DIR}3013_36_r2.fq.gz|${RAW_DIR}3013_mCh1_r1.fq.gz|${RAW_DIR}3013_mCh1_r2.fq.gz|${RAW_DIR}3013_mCh2_r1.fq.gz|${RAW_DIR}3013_mCh2_r2.fq.gz|${RAW_DIR}3013_mCh3_r1.fq.gz|${RAW_DIR}3013_mCh3_r2.fq.gz|${RAW_DIR}3013_mCh4_r1.fq.gz|${RAW_DIR}3013_mCh4_r2.fq.gz|${RAW_DIR}3013_nc1_r1.fq.gz|${RAW_DIR}3013_nc1_r2.fq.gz| sed 's/ //g'`
I am expecting the files to be read in one by one successfully but at the moment all files read in after the first successful file error out with "Permission denied".
Upvotes: 1
Views: 130
Reputation: 9855
Since you use pipe characters in the command
ls -m ${RAW_DIR}3013_12_r1.fq.gz|${RAW_DIR}3013_12_r2.fq.gz|${RAW_DIR}3013_14_r1.fq.gz ...
you only pass the first file name as an argument to ls -m
and you create a pipe. That means the shell will connect the output of one program to the input of the next program.
The shell will try to execute ${RAW_DIR}3013_12_r2.fq.gz
, ${RAW_DIR}3013_14_r1.fq.gz
etc. as programs.
Most probably these files are not executable, that's why you get the error message. (The file doesn't have execute permission.) And most probably this is not what you want.
If you want to specify more than one argument (file name) to a program, separate the arguments with space.
Maybe you want something like
FILES=`ls -m ${RAW_DIR}3013_12_r1.fq.gz ${RAW_DIR}3013_12_r2.fq.gz ${RAW_DIR}3013_14_r1.fq.gz ${RAW_DIR}3013_14_r2.fq.gz ${RAW_DIR}3013_15_r1.fq.gz ${RAW_DIR}3013_15_r2.fq.gz ${RAW_DIR}3013_16_r1.fq.gz ${RAW_DIR}3013_16_r2.fq.gz ${RAW_DIR}3013_31_r1.fq.gz ${RAW_DIR}3013_31_r2.fq.gz ${RAW_DIR}3013_33_r1.fq.gz ${RAW_DIR}3013_33_r2.fq.gz ${RAW_DIR}3013_34_r1.fq.gz ${RAW_DIR}3013_34_r2.fq.gz ${RAW_DIR}3013_36_r1.fq.gz ${RAW_DIR}3013_36_r2.fq.gz ${RAW_DIR}3013_mCh1_r1.fq.gz ${RAW_DIR}3013_mCh1_r2.fq.gz ${RAW_DIR}3013_mCh2_r1.fq.gz ${RAW_DIR}3013_mCh2_r2.fq.gz ${RAW_DIR}3013_mCh3_r1.fq.gz ${RAW_DIR}3013_mCh3_r2.fq.gz ${RAW_DIR}3013_mCh4_r1.fq.gz ${RAW_DIR}3013_mCh4_r2.fq.gz ${RAW_DIR}3013_nc1_r1.fq.gz ${RAW_DIR}3013_nc1_r2.fq.gz| sed 's/ //g'`
If you want all file names in ${RAW_DIR}
you can use
FILES=$(ls -m ${RAW_DIR}*| sed 's/ //g')
or if you want to be more specifc
FILES=$(ls -m ${RAW_DIR}*.fq.gz| sed 's/ //g')
Upvotes: 1