From f5acbc23f330d2a6f4f5c46b63f807dc068d34e5 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Wed, 23 Dec 2020 10:41:42 +0100 Subject: [PATCH] Add script for extracting archives until you get text --- .../scripts/pieces/extract-until-text.sh | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 arch-config/scripts/pieces/extract-until-text.sh diff --git a/arch-config/scripts/pieces/extract-until-text.sh b/arch-config/scripts/pieces/extract-until-text.sh new file mode 100644 index 00000000..3db51aec --- /dev/null +++ b/arch-config/scripts/pieces/extract-until-text.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Script by RealStickman +# https://gitlab.com/RealStickman + +file="$1" +count=1 + +while [[ ! $(file "$file" | grep "ASCII text") ]]; +do + if [[ $(file "$file" | grep "POSIX tar archive") ]]; then + tar -xvOf "$file" > taroutfile"$count" + file="taroutfile$count" + ((count=count+1)) + echo "Using tar" + fi + if [[ $(file "$file" | grep "bzip2 compressed data") ]]; then + bzip2 -dc "$file" > bzoutfile"$count" + file="bzoutfile$count" + ((count=count+1)) + echo "Using bzip2" + fi + if [[ $(file "$file" | grep "gzip compressed data") ]]; then + mv "$file" "$file".gz + gzip -dc "$file".gz > gzoutfile"$count" + file="gzoutfile$count" + ((count=count+1)) + echo "Using gzip" + fi +done +echo "Finished" +mv "$file" "output.txt" +echo "Your content is in output.txt"