This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Running bash script

Hi everyone, How can I run a loop similar to this regardless of the order of the listed commands.

for file in 
do
  head -n 2 $filename | tail -n 1
done

I would appreciate any recommendation and thanks in advance.

bash

What do you mean when you say regardless of the order of the commands?

I mean I need to run a similar script by using variables equivalent to tail, head and file name. But the user can insert them in any order and it will run the script correctly according to the user needs. I can provide the user key or guide to guide them how to use the script.

similar to this loop

  -h 19 -f file name -t 3 

but the user type it in any order.

1 answer

Copy this into myscript.sh and run bash myscript.sh. You will need to replace *.fastq with whatever satisfies your conditions.

#!/bin/bash
for file in *.fastq
do
head -n 2 $file | tail -n 1
done

Log in to answer this question.