W
W
wolverine7772021-01-24 17:33:39
linux
wolverine777, 2021-01-24 17:33:39

How to add number to output file by iteration?

Hello, I have three files in the B4627 directory:

1_S_R1_001.fastq.gz
2_S_R1_001.fastq.gz
3_S_R1_001.fastq.gz


I need my script to perform an operation with each of the files and the output is the corresponding fileexit_1.sam, exit_2.sam, exit_3.sam

#!/bin/bash

for FILE in *R1_001.fastq.gz;

do
BASENAME=${file%%_R1_001.fastq.gz*}
        echo   "bowtie2 -x covexp -U B4627/$FILE -S exit.sam" ;
done


To separate numbers in files, I can only think of this for now: what do I need to add to the script so that only its number is displayed with each file? Thanks PS Of course, the echo in the script is just to check if the loop is working properly..

ls -l | awk '{print $9}' | sed 's/_S.*$//'

exit.sam


Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
planc, 2021-01-24
@planc

for i in *R1_001.fastq.gz;do basename $i _S_R1_001.fastq.gz;done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question