- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - Linux
- >
- General
- >
- Extracting from multiple tar files: Oneliner wante...
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-23-2008 03:00 AM
09-23-2008 03:00 AM
I'm extracting files from multiple tar files. This for-loop works:
$ for xx in `ls -1`; do tar xvf $xx; done
but why doesn't this little thing work?
$ ls -1 |awk '{print $1}' | tar xvf -
Tar gives no error message, but no extracting gets done. Puzzling...
Any pointers or comments?
Regards,
Runar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-23-2008 05:25 AM
09-23-2008 05:25 AM
Re: Extracting from multiple tar files: Oneliner wanted
cat test.tar | tar tvf -
ls test.tar | tar tvf -
You are trying to do the second one, that won't ever work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-23-2008 08:51 PM
09-23-2008 08:51 PM
Re: Extracting from multiple tar files: Oneliner wanted
Try below shell code for extracting many files.
tar_files=`ls *.tar 2>/dev/null`
if [ -n "$tar_files" ]
then
for i in $tar_files
do
tar -zxvf $i 2>&1
done
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-23-2008 11:08 PM
09-23-2008 11:08 PM
Re: Extracting from multiple tar files: Oneliner wanted
I'm curious about your reply. I believed tar wanted a one-by-one list of file names as input. But, what you are saying is that I'm really supposed to supply the content of the tar files?
If I have two tar files FILE1.tar and FILE2.tar, Then this (below) should work, but it doesn't. Tar only extracts the first tar file. How come?
$ ls
FILE1.tar FILE2.tar
$ tar tvf FILE1.tar
-rw-r--r-- runar/wheel 401021 2008-02-27 08:42:06 typescript
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript1
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript10
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript2
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript3
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript4
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript5
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript6
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript7
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript8
-rw-r--r-- runar/wheel 0 2008-02-27 12:26:14 typescript9
$ tar tvf FILE2.tar
-rw-r--r-- runar/wheel 144244 2008-02-27 12:39:21 find_xargs.log
-rw-r--r-- runar/wheel 0 2008-02-27 12:28:15 fred.foo
$ cat *.tar | tar xvf -
typescript
typescript1
typescript10
typescript2
typescript3
typescript4
typescript5
typescript6
typescript7
typescript8
typescript9
runar@MMtux:~/tmp$ ls
FILE1.tar typescript typescript10 typescript3 typescript5 typescript7 typescript9
FILE2.tar typescript1 typescript2 typescript4 typescript6 typescript8
Troy,
Thanx for the script.
Regards,
Runar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-24-2008 06:23 AM
09-24-2008 06:23 AM
Solutioncat tar1.tar > tar3.tar
cat tar2.tar >> tar3.tar
At that point, you should have tar1 and tar2 in the tar3.tar file. But the problem is that tar1.tar also stored it's end of tar archive mark in the file, so, you won't be able to continue above the end of the tar1 content even in the tar3 file.
As you cannot "forward" a mark in the tarfile as in a tape (mt fsf), probably you won't be able to read the second tar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-24-2008 04:41 PM
09-24-2008 04:41 PM
Re: Extracting from multiple tar files: Oneliner wanted
from tape:
while [ $? == 0 ] ; do tar xvf /dev/nst0
for a directory on disk
for x in $(ls
I also pipe the output to a file for review if needed.
Ray
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
09-26-2008 12:16 AM
09-26-2008 12:16 AM
Re: Extracting from multiple tar files: Oneliner wanted
Thanx
Runar
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP