Created
November 18, 2019 08:03
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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