I need to create a lot of files for testing, however I've failed at the first hurdle! Here's what I've set out to achieve and broken down into tasks:
I have cd'd into the correct dir before the above code btw.
Can anyone help please?!
- Read a CSV file containing a few thousand rows of data (only one column)
- Create a directory with a unique name (in the format X_DD-MM-YYYY_HH-MM-SS) eg. 1_24-06-2018-00-00-01 - hoping I can increment the time value to make the dir unique?
- Grab the value from the CSV and store it as a variable
- Create a .json file with the above variable used once in one of the json fields and the directory name in one of the json fields
- Save the .json file in the above dir
- Copy a PDF file from another dir (I should be able to do this using the 'cp' function)
- Zip up the new folder with the .json file and the PDF file
Code:
while IFS="," read -r f1
do
#create a unique int that increments through each loop
int i=1
#print the case number from each row
echo $f1
#create the directory for each zip file using mkdir
mkdir 1_24-06-2018-00-00-$i
#cd into the new directory
cd 1_24-06-2018-00-00-$i
done < CCD_CaseList_01-10-2018_1only.csv
I have cd'd into the correct dir before the above code btw.
Can anyone help please?!