• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Urban Penguin

The Urban Penguin - Linux Training

  • Home
  • About
  • Live Online Courses
  • Shop
  • RHCSA Guide
  • Programming
    • Master Editing Text Files Using VIM
    • Learn Shell Scripting with BASH
    • PERL Scripting in Linux
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • Learn C Programming using Linux and the Raspberry Pi
    • General Java Tutorials
    • Java 7 OCA Exam 1ZO-803
  • OS Tutorials
    • Red Hat and CentOS Training
      • Red Hat Enterprise Linux System Administration 1 – RH124
      • RHCSA – System Admin 2 – RH134
      • RHCE – EX294 – Automation With Ansible
    • Learning Ubuntu
    • LPI Training
      • LPI Linux Essentials
      • LPIC-1 Linux Administrator
      • LPIC-2 Certified Linux Engineer
      • LPIC-3 Senior Level Certification
        • LPIC-3 Exam 300 : Mixed Environments
        • LPIC-3 Exam 303 : Security
        • LPIC-3 Exam 304 : Virtualization and High Availability
    • Linux Technologies
      • Apache HTTPD Server
      • Learning PHP
      • Learning PUPPET
      • Learning SAMBA
      • Linux File-Systems
      • Monitoring with Nagios Core
      • MYSQL
      • openLDAP Directories on Linux
You are here: Home / Linux / tar / Appending and Combining Tar Archives

Appending and Combining Tar Archives

March 31, 2018 by The Urban Penguin

Appending and Combining Tar ArchivesIn the last tutorial we looked a look at compressing archives. We continues look at GNU tar and this time we look at appending and combining tar archives.

Appending to Archives

Appending and combining tar archives are similar so we have added them to the same tutorial, however, they are covered individually as they are not the same. If you have an existing archive to which you want to add new files, this can be done using the long option of –append or the short option of -r. This will append files to an archive. If the need is to joint two archives together then the option –-concatenate should be used. We will look at appending to archives first. We will start by creating a new archives and then add a file to it.

$ tar --create --file=my.tar /etc/services     
 tar: Removing leading `/' from member names
 $ tar --list --file=my.tar
 etc/services
 $ tar --append --file=my.tar /etc/hosts    
 tar: Removing leading `/' from member names
 $ tar --list --file=my.tar             
 etc/services
 etc/hosts

This becomes a great option where we need to keep all related file togther once they have been worked on. You can imagine crrating a series of scripts that perform related activities. Once a script has been completed it can be appended to the application archive.

Of course, more than one file or directory can be appended to the archive, what we see here is a just a simple example.

Combining Archives

As we mentioned before, if we need to combine two or more archives we can use the –concatenate option or -A. The archives must be combined to an existing archive which is specified with the –file option. Any amount of archives can be combined to the single archive specified.In this example we create two new archives and combine then together into the single archive.

$ tar --create --file=file1.tar /etc/hosts /etc/hostname
 tar: Removing leading `/' from member names
 $ tar --list --file=file1.tar
 etc/hosts
 etc/hostname
 $ tar --create --file=file2.tar /etc/services
 tar: Removing leading `/' from member names
 $ tar --list --file=file2.tar
 etc/services
 $ tar --concatenate --file=file1.tar file2.tar
 $ tar --list --file=file1.tar
 etc/hosts
 etc/hostname
 etc/services

The video follows:

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to print (Opens in new window)

Filed Under: tar

Primary Sidebar

Newest Video

The Urban Penguin On Youtube

Products

  • Complete RHCSA 8 Study Guide Complete RHCSA 8 Study Guide £5.99
  • SELinux Guide SELinux Fundamentals in Red Hat Enterprise Linux 8 £1.99
  • Managing POSIX ACLS in Linux £0.99
  • Managing Linux File Permissions £0.99
  • Kernel Module Administration in Linux £0.99

Categories

Pages

  • About The Urban Penguin
  • Contact Us
  • Shop
    • Basket
    • Checkout
    • My Account
  • LPI Training from The Urban Penguin
    • Live and Pluralsight hosted courses
    • Complete Linux Essentials
    • LPIC-3 Senior Level Certification
      • LPIC-3 Exam 300 : Mixed Environments
      • LPIC-3 Exam 303 : Security
      • LPIC-3 Exam 304 : Virtualization and High Availability
    • LPIC-2 Certified Linux Engineer
    • LPIC-1 Linux Administrator
    • LPI Linux Essentials for Raspberry Pi
    • LPI Linux Essentials
  • Operating System Tutorials
    • Linux Foundation Training
    • Solaris 11 OCA 1ZO-821
    • Learning Ubuntu
    • Learning SUSE
    • Red Hat and CentOS Training
      • RHCE – EX294 – Automation With Ansible
      • RHCSA – System Admin 1 – RH124
      • RHCSA – System Admin 2 – RH134
  • Scripting – the power of repetition!
    • Java 7 OCA Exam 1ZO-803
    • General Java Tutorials
    • Learn C Programming using Linux and the Raspberry Pi
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • PERL Scripting in Linux
    • Learn Shell Scripting with BASH
    • Master Editing Text Files Using VIM
  • Linux Technologies
    • Learning PUPPET
    • openLDAP Directories on Linux
    • Monitoring with Nagios Core
    • Linux File-Systems
    • Learning SAMBA
    • Apache HTTPD Server
    • Learning PHP
    • MYSQL
  • OpenStack
    • Pluralsight
    • Udemy
    • Raspberry Pi Tutorials
    • Citrix Videos
  • Online Instructor-led Courses
    • Red Hat Enterprise Linux System Administration 1 – RH124
    • SELinux Masterclass
    • Bash Scripting Masterclass
    • Nftables Masterclass

© 2021 The Urban Penguin · All Rights Reserved

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok