Как я могу сделать рекурсивную распаковку с терминала? [dубликат]

Поскольку вы начали screen с screen -S R, вы сначала начали с оболочки внутри сеанса экрана, возможно, bash. Таким образом, вы можете воспользоваться управлением работой bash, нажав Ctrl + Z, чтобы приостановить процесс R, а затем возобновить его позже с помощью fg:

[1] 7221
[1] 7222
[1] 7223
[1] 7224
^Z
[1]+  Stopped                 R

$ fg
[1] 7225
1
задан 1 March 2018 в 19:05

3 ответа

Мое предложение состоит в том, чтобы создать пользовательскую команду, добавив следующую функцию в ваш .bashrc:

# Recursive UNZIP 
# - covers only the firs level of the recursion; 
# - works only with one input file
unzipr () {
    # Get the users input
    TARGET_ZIP_FILE="${1}"

    # Get the list of sub archive zip files
    ZIP_LIST="$(unzip -l "$TARGET_ZIP_FILE" | awk 'NR > 1 && $NF ~ /zip/ { print $NF }')"

    # Output the list of sub archive zip files
    if [ ! -z "${ZIP_LIST}" ]; then
        echo 'List of Sub Archives:'
        for ZIP in $ZIP_LIST; do echo -e " - $ZIP"; done; echo
    else
        echo "Sub Archives Not Found."
    fi

    # Extract and unzip the files
    for ZIP in $ZIP_LIST; do
        # Ask the user for his/her preferences
        echo -n "Do you want to extract and unzip \"$ZIP\" [Y|n]: "
        read preference

        # Extract the file according to the users preferences
        if [ -z "${preference}" ] || [[ "${preference}" =~ ^(y|Y).* ]]; then
            unzip "$TARGET_ZIP_FILE" "$ZIP"
            unzip "$ZIP"
            rm "$ZIP"
            echo
        fi
    done
}

Добавьте эти строки в конец ~/.bashrc, затем сделайте source ~/.bashrc, и вы будет иметь команду под названием unzipr. Вот как это работает:

2
ответ дан 22 May 2018 в 12:49

Мое предложение состоит в том, чтобы создать пользовательскую команду, добавив следующую функцию в ваш .bashrc:

# Recursive UNZIP # - covers only the firs level of the recursion; # - works only with one input file unzipr () { # Get the users input TARGET_ZIP_FILE="${1}" # Get the list of sub archive zip files ZIP_LIST="$(unzip -l "$TARGET_ZIP_FILE" | awk 'NR > 1 && $NF ~ /zip/ { print $NF }')" # Output the list of sub archive zip files if [ ! -z "${ZIP_LIST}" ]; then echo 'List of Sub Archives:' for ZIP in $ZIP_LIST; do echo -e " - $ZIP"; done; echo else echo "Sub Archives Not Found." fi # Extract and unzip the files for ZIP in $ZIP_LIST; do # Ask the user for his/her preferences echo -n "Do you want to extract and unzip \"$ZIP\" [Y|n]: " read preference # Extract the file according to the users preferences if [ -z "${preference}" ] || [[ "${preference}" =~ ^(y|Y).* ]]; then unzip "$TARGET_ZIP_FILE" "$ZIP" unzip "$ZIP" rm "$ZIP" echo fi done }

Добавьте эти строки в конец ~/.bashrc, затем сделайте source ~/.bashrc, и вы будет иметь команду под названием unzipr. Вот как это работает:

2
ответ дан 17 July 2018 в 19:45

Мое предложение состоит в том, чтобы создать пользовательскую команду, добавив следующую функцию в ваш .bashrc:

# Recursive UNZIP # - covers only the firs level of the recursion; # - works only with one input file unzipr () { # Get the users input TARGET_ZIP_FILE="${1}" # Get the list of sub archive zip files ZIP_LIST="$(unzip -l "$TARGET_ZIP_FILE" | awk 'NR > 1 && $NF ~ /zip/ { print $NF }')" # Output the list of sub archive zip files if [ ! -z "${ZIP_LIST}" ]; then echo 'List of Sub Archives:' for ZIP in $ZIP_LIST; do echo -e " - $ZIP"; done; echo else echo "Sub Archives Not Found." fi # Extract and unzip the files for ZIP in $ZIP_LIST; do # Ask the user for his/her preferences echo -n "Do you want to extract and unzip \"$ZIP\" [Y|n]: " read preference # Extract the file according to the users preferences if [ -z "${preference}" ] || [[ "${preference}" =~ ^(y|Y).* ]]; then unzip "$TARGET_ZIP_FILE" "$ZIP" unzip "$ZIP" rm "$ZIP" echo fi done }

Добавьте эти строки в конец ~/.bashrc, затем сделайте source ~/.bashrc, и вы будет иметь команду под названием unzipr. Вот как это работает:

2
ответ дан 23 July 2018 в 20:30

Другие вопросы по тегам:

Похожие вопросы: