0

Hi I am using this script named analysis.sh

#!/bin/bash

SAMPLENAME=$1;
SAVEDATA=$2;
DATAPATH=$3;
REFERENCE=$4

......

I want to give input of multiple files in CSV format instead of putting individual files details every time as to multiple files can be parsed through single script.

e.g. i have two files ABC and XYZ

so in order to analyse these two files i give these commands

For ABC

analysis.sh ABC /home/myfolder1  /home/datafolder1 /home/referncefolder1

and for XYZ

analysis.sh XYZ /home/myfolder2  /home/datafolder2 /home/referncefolder2

if i have 100 different files, how to use a single CSV file with details of these 100 files in it that can be parsed through the command line arguments of this bash script?

Community
  • 1
  • 1
RonicK
  • 229
  • 2
  • 3
  • 10

1 Answers1

0

You can pass the name of the csv file as a single argument and have your script read it line by line:

csv=$1
while IFS=, read -r filename savedata datapath reference; do
  # do the processing
done < "$csv"

See this post to understand more about how to read a text file in Bash:

You may want to read more about the shell variable naming convention:

codeforester
  • 39,467
  • 16
  • 112
  • 140