Skip to content

Instantly share code, notes, and snippets.

@bokwoon95
Created November 18, 2019 08:03
Show Gist options
  • Save bokwoon95/c5f927cae43e9591b7585fadbcec4739 to your computer and use it in GitHub Desktop.
Save bokwoon95/c5f927cae43e9591b7585fadbcec4739 to your computer and use it in GitHub Desktop.
Dump the list of filenames of all *.tar.xz files in the current directory into a text file (parallelized by xargs)
#!/bin/bash
dump_tar_xz_contents() {
total="$1"
index="$2"
file="$3"
file_without_extension="$(basename "$file" .tar.xz)"
echo "[START][$index/$total] $file"
tar tf "$file" > "$file_without_extension.txt"
echo "[END][$index/$total] $file"
}
export -f dump_tar_xz_contents
total_files="$(find . -type f -name '*.tar.xz' | wc -l)"
find . -type f -name '*.tar.xz' | awk '{print NR " " $0}' | xargs -I{} -P30 -- bash -c "dump_tar_xz_contents $total_files {}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment