0

I want to create a script that creates a new folder with the name of the first argument in the directory specified as the second argument.

#!/bin/bash -e

Passing Arguments (fastq data and directory where generate the output) into this script

$fastq_file $new_directory

Create the new directory

mkdir $new_directory/$fastq_file

I have also tried mkdir "$new_directory"/"$fastq_file"

After saving and closing

I have tried to run the script with this

my_script 12345.fastq ./

The desired output should be a new folder in the current directory called 12345

If the user instead of my_script 12345.fastq ./ would have been my_script 12345.fastq /home/folder1/folder2

I would like to get a new folder called 12345 in the directory /home/folder1/folder2

However, after many attends I always get the error: mkdir: cannot create directory `/': File exists

1 Answers1

0

I hope I understood what you wanted correctly...

#!/bin/bash -e

new_directory=$1
fastq_file=$2

mkdir -p $new_directory/$fastq_file

The script accept two arguments. First is the first directory name, second is the second directory name.

./script 12345 folder2
Alex
  • 1,958