Work with ZIP archive at Bash

Work with ZIP archive at Bash

By : Anumol Pradeep
Date : November 18 2020, 11:13 AM
I hope this helps you . I need to write a simple Bash script. How to unzip archive (in the same directory) with several files and get a path to these unpacked files? Path to archive is in $1 attribute. And how to pack these files back in new archive with $2 path? , If the zipfile is foo.zip, to unzip the archive, you can do
code :
unzip foo.zip
zipinfo -1 foo.zip

Share : facebook icon twitter icon
bash: extract only part of tar.gz archive

bash: extract only part of tar.gz archive

By : Timothy Lee Wietzke
Date : March 29 2020, 07:55 AM
To fix the issue you can do OK, so based on this answer, I can list all contents at the desired depth. In my case, the tar.gz file is structured as follows:
code :
mkdir $parent_folder
for subdir in `tar --exclude="*/*/*" -tf archive.tar.gz`; do
    if [ "$subdir" = "$parent_folder" ];
        echo 'not this one'
    if [ "$counter" -lt "$max_num" ];
        tar zxvf archive.tar.gz $subdir -C ./${parentfolder}${subdir}
        counter=$((counter + 1))
mkdir $parent_folder
for subdir in `tar --exclude="*/*/*" -tf files.tar.gz`; do
    if [ "$subdir" = "$parent_folder" ];
        echo 'not this one'
    if [ "$counter" -ge "$max_num" ];
        tar zxvf files.tar.gz $subdir -C ./${parent_folder}$subdir
    counter=$((counter + 1))
Create zip archive(bash script)

Create zip archive(bash script)

By : roma patil
Date : March 29 2020, 07:55 AM
Hope that helps As pointed by Rick, use zip command:
zip -r ../zipfolder/folders.zip ../folder1 ../folder2 ../folder3
Bash script for archive logs

Bash script for archive logs

By : Ahmed Azim
Date : March 29 2020, 07:55 AM
wish helps you We can connect many commands and features of bash to develop solution. Here's my version:
code :


# That directory probably exists already but let us say it doesn't

find "$LOG_SOURCE" -type d -regextype gnu-awk -regex "$LOG_SOURCE/[[:digit:]]{4}/[[:digit:]]{2}/[[:digit:]]{2}" \
    | sed -r -n 's#^.*([0-9]{4})/([0-1][0-9])/([0-3][0-9])$#\1 \2 \3#p' \
    | while read Y M D; do
        if [[ "$Y$M$D" < $(date "+%Y%m%d" -d "$ARCHIVE_AFTER days ago") ]]

            echo $logArchiveSrcDirectory
            echo $logArchiveDstZipFile

            if zip -r  "$logArchiveDstZipFile" "$logArchiveSrcDirectory"
                rm -r "$logArchiveSrcDirectory"

Automator bash unix script, read input files to move if single file or detect if multiple archive and then move archive

Automator bash unix script, read input files to move if single file or detect if multiple archive and then move archive

By : Remon
Date : March 29 2020, 07:55 AM
I wish this helpful for you I have a droplet made with automator, which moves files when I drop them on application icon to certain folder. , Use a conditional, something like (syntax might be way off):
Filter messages from FB archive using bash

Filter messages from FB archive using bash

By : johnnyK
Date : March 29 2020, 07:55 AM
it fixes the issue I have a little problem. I need to filter a really messy .htm file. It has got no newlines, its just a really long string of mess. , grep loves these things:
Related Posts Related Posts :
  • syslog Log/ Event generator linux
  • Ping timeout issues
  • How make /var/www contents editable by IDE
  • Why ordinary user cannot use chgrp/chown
  • Execute a script on startup of SUSE reboot
  • Extracting debugging information from core files
  • linux command to connect to another server using hostname and port number
  • GLib.Settings.changed event not firing
  • What does it mean by code holding semaphore can be preempted
  • Does LD_LIBRARY_PATH really cause inconsistencies?
  • "lsof" shows a file as (deleted) but I can still see it in file system
  • Linux file deleted recovery
  • Exchange columns in bash
  • How to set max file size in Linux CeNTOS to server.log
  • Regular expressions: Search a word and append a new word at the end of the line
  • Compress a set of log files in a folder depending on number of files
  • unexpected behavior of linux malloc
  • relation between init and bash terminal process
  • Matlab VideoReader codec error?
  • How to catch the L3-cache hits and misses by perf tool in Linux
  • Executable Deleting Itself on linux
  • How to change the apache httpd port for serving files
  • Installing Patches in linux
  • Comparative analysis between libkvm on linux and NetBSD
  • How to join multiple txt files into based on column?
  • setting LINK variable in Makefile generated by qmake (5.0)
  • Automake - difficulty with installing version 'automake-1.14.1'
  • How to use Linux Network Namespaces for per processes routing?
  • How can I write a Gruntfile with different shell command behaviour for OS X vs. Linux?
  • Using at command in shell script for scheduling a command
  • Is there a method to figure out the audio channel layout in Linux?
  • Setting environment varilable for daemon / root process
  • string replacement in shell script
  • Add specific column to the end of a CSV file
  • Are there programmable automount/autofs hooks in linux/systemd?
  • Renaming files like 20141207_190822.jpg to "2014-12-07 19.08.22.jpg" in linux or MacOS X
  • undocumented kernel boot parameter?
  • using wget to mirror a website with path and subfolder that have the same name
  • Using awk to find data matching date range in text file
  • Installing xorg-x11-devel package in SLES 11 SP2
  • Setting result of find to variable, which has variables within it
  • Maximum/Minimum physical address - Linux kernel
  • Freepbx custom context outbound route
  • memcpy implementation in linux kernel
  • How to reverse a list of words in a shell string?
  • Concatenate and pass as parameter in bash
  • Add user to Docker container
  • How to add a content in a file in linux without opening the file using vi or cat command
  • Which SVN subversion can I use on linux, Mac, Windows?
  • bash script not running as expected from cron vs. shell.
  • Compare one field, Remove duplicate if value of another field is greater
  • sudoers NOPASSWD: sudo: no tty present and no askpass program specified
  • How do I use pipes and variable substitution in a shell script (for toggling haproxy active server)?
  • Linux/Unix Find Command
  • Not able to copy data in hdfs with hdfs dfs commands
  • Linux : Remove/Delete .txt files ending with exactly five digits
  • ARM assembly "retne" instruction
  • Migrate from LXC to LXD
  • sbt on linux not accepting -jvm-debug 5005
  • Supervisord events only sent to one eventlistener in pool
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org