everyone. I have CSV file with ~1.5mil strings with column "ArchiveName", and i'm trying to unzip every archive with script:
#!/bin/bash
csvPath=/any/folder/ArchiveName.csv
archiveFolderPath=/any/archives
cd $archiveFolderPath
while IFS=";" read -r ArchiveName
do
unzipPath=/any/unzip
sudo unzip "${ArchiveName}" -d "${unzipPath}"
done < <(tail -n +1 $csvPath)
When i'm start script - get error "Argument list too long"
i'm tried to cut csv file to 5k string, but it still doesn't work.. How i can change script or csv to make it alive?
"Argument list is too long" means: one of the strings you pass to
sudo unzip "${ArchiveName}" -d "${unzipPath}"is too long (not: there are too many lines in your csv).One way to debug that issue is to check what values are passed to your command:
If you have long csv lines where ArchiveName is the first field: you got tricked by the behavior of
read.readwill place all the remaining fields in the last variable you specify. Here is an example:In your code:
ArchiveNamecontains the complete csv line (not: just the first field)Just add a second variable to your call to
read: