0

I have a directory(INPUTDIR) with sample names as subdirectories(508_C,540_C,570_D etc).Within those each subdirectories there is another directory called FASTQ which contains two kinds of files.

e.g.

540_Ct_1.fastq.gz
540_Ct_2.fastq.gz

I want to create two lists,the first having all _1.fastq.gz filenames with paths and the other having _2.fastq.gz filenames with paths.

The directory structure is

INPUT DIR > 508_C >FASTQ > 508_1.fastq.gz 508_2.fastq.gz
INPUT DIR > 540_C >FASTQ > 540_Ct_1.fastq.gz 540_Ct_2.fastq.gz
INPUT DIR > 570_D >FASTQ >570_Ct_1.fastq.gz 570_Ct_2.fastq.gz

The INPUTDIR is the main directory.I want to create TWO lists in this directory. One list has :

/home/user/INPUT DIR > 508_C >FASTQ > 508_1.fastq.gz 
/home/user/INPUT DIR > 540_C >FASTQ > 540_Ct_1.fastq.gz 
/home/user/INPUT DIR > 570_D >FASTQ > 570_Ct_1.fastq.gz 

The second list has:

/home/user/INPUT DIR > 508_C >FASTQ >508_2.fastq.gz
/home/user/INPUT DIR > 540_C >FASTQ > 540_Ct_2.fastq.gz
/home/user/INPUT DIR > 570_D >FASTQ >  570_Ct_2.fastq.gz

Thanks,

Ron

2
cd INPUTDIR
find . -name \*1.fastq.gz > list1
find . -name \*2.fastq.gz > list2

The paths in the "list" files will be relative to the current directory. If you want absolute paths, use

find "$PWD" -name \*1.fastq.gz > list1
2
  • Hi Glenn.Just a quick question for learning purpose.If we don't want the whole path but just want the file names.I tried to use find -name *1.fastq.gz ,along with some other methods but don't work.
    – Ron
    Dec 4 '14 at 15:53
  • 2
    find . -name \*1.fastq.gz -printf "%f" > list1 -- check the find man page for details. Dec 4 '14 at 18:24

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .