I'm very new to scripting and working in Unix/Linux systems, so I appreciate any help. I'm sure this has been answered before but I cannot figure out why none of the other solutions are working for my case.
I have a directory with several gzip-compressed ASCII text files. I need to separate these based on the file name depending on the presence of the strings
v4 at the 5th and 6th position of the name.
Here is an example of what my filenames look like within the directory:
M07Zv3REP1_S442_L001_R1_001.fastq.gz M07Zv3REP1_S442_L001_R2_001.fastq.gz M18ZitREP3_S276_L001_R2_001.fastq.gz M10ZrbREP3_S535_L001_R1_001.fastq.gz M10ZrbREP3_S535_L001_R2_001.fastq.gz M09Zv4REP1_S300_L001_R1_001.fastq.gz M09Zv4REP1_S300_L001_R2_001.fastq.gz
I've tried using a number of different grep options, but they return every file. For example
grep -FLZ "rb" *.fastq.gz
I figure I'll use xargs to move the grepped files to a new directory, but I'm stuck on how to get the correct zipped files to match. It may be the problem is that grep is searching WITHIN each of the fastq files, in which case there may be an "rb" or an "it" in there somewhere so everything is getting returned.
Any help is much appreciated!