This code was written to extract multiple .tar files to another location and woks fine
ls -1 ${short_filename} \
| while read file; do \
tar -zxvf "$file" -C ${pentaho_temp_path}/${sessionkey}; \
done
I want to do the same for .gz files on a Linux machine. My files have no whitespace in their names and they look like this:
xport_RAN_Maa_LIM_10.93.217.170_20220629030929.xml.gz
xport_RAN_Maa_LIM_10.93.217.170_20220630030936.xml.gz
xport_RAN_Mau_MPU_10.188.83.138_20220629031403.xml.gz
xport_RAN_Mau_MPU_10.188.83.138_20220630031444.xml.gz
ls; not even with-1: Filenames can have all kinds and numbers of line breaks in them! Afor file in ${short_filename}/*;instead of thels .. | while read…would be safer, shorter, faster and nicer to read! – Marcus Müller Jul 01 '22 at 09:16short_filename. Instead of parsing the output oflsyou should better use aforloop. The details depend on the value ofshort_filename. – Bodo Jul 01 '22 at 09:18xport_RAN_Maa_LIM_10.93.217.170_20220630030936.xml.gz
xport_RAN_Mau_MPU_10.188.83.138_20220629031403.xml.gz
xport_RAN_Mau_MPU_10.188.83.138_20220630031444.xml.gz – Wessley Jul 01 '22 at 09:22
short_filenameis a single filename, a directory name or a wildcard. – Bodo Jul 01 '22 at 09:28$short_filenamea single filename, a pattern, or something else? – Kusalananda Jul 01 '22 at 10:17