'How to loop through the values of a csv (or txt file) in command line
I have a csv file saved that holds several historical git commit hashes and dates that correspond to each commit. I want to checkout each one of these hashes and then save a specific folder (the forecast folder) from each historical commit into an outside directory. After it's saved, I'd like to change the name of the folder to hold the corresponding date for that specific hash value that is stored in the csv. I have never written a script to run directly on the command line, but am fairly versed in writing R scripts. If I was able to do this all in R, the following would be what my code would resemble (where the csv has been converted into a matrix):
csv_file<-as.matrix(csv_file)
for (i in nrow(csv_file)){
#csv_file[i,1] holds each historical commit hash
git checkout csv_file[i,1]
#copy Forecasts folder to external path
cp -r Forecasts <external_path>
#change the folder name from "Forecasts" to the corresponding date value (csv_file[i,2] holds
#the dates corresponding to each historical commit)
mv external_path/Forecasts external_path/csv_file[i,2]
}
How could I rewrite this code to work solely on the command line?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
