[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

ýTAR only one directory levelý

Posted on 2000-04-20
5
Medium Priority
?
285 Views
Last Modified: 2010-04-21
ýMy directory structure is the following:ý

ý/root/1/ý
ý/root/1/aý
ý/root/1/bý
ý/root/1/cý
ý/root/2/ ý
ý/root/2/aý
ý/root/2/bý
ý/root/2/cý
ý…ý
ý/root/999/ ý
ý/root/999/aý
ý/root/999/bý
ý/root/999/cý

ýI would like to tar in one command only the 1st directory levelý
ýAfter root (i.e.  /root/1, /root/2 …/root/999). So that ý
ý/root/1/a  /root/1/b will not be TAR.ý
ýRight now I’m using this command:ý

ýtar -cf - /root | gzip > /home/rami/all_root.tgzý


ýWhich TAR much more then I needý

ýRegards,ý
ýRami Addadyý



0
Comment
Question by:addady
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:tfewster
ID: 2736391
By default, tar recurses down subdirectories; You can exclude files with -X list_of_files_to_exclude, so the following shell script ("arch_dir")will do the job:

#!/bin/sh
#arch_dir:
#Archive directory structure & files at
#top level

# Get full list
find /root > /tmp/rootlist
# Get list of files > 1 level down
grep "/./" /tmp/rootlist > /tmp/exclude
tar -cf - -X /tmp/exclude /root | gzip > /home/rami/all_root.tgz

rm /tmp/rootlist
rm /tmp/exclude

This is inefficient as it has to traverse the full directory tree to generate the list of files to exclude, but once you've created it as a shell script you only have to type one command to run it :)


0
 

Author Comment

by:addady
ID: 2741237
This question has a deletion request Pending
0
 

Author Comment

by:addady
ID: 2741239
the comment answer my question
0
 
LVL 21

Expert Comment

by:tfewster
ID: 2741410
This question no longer is pending deletion
0
 
LVL 21

Accepted Solution

by:
tfewster earned 400 total points
ID: 2741412
Glad to hear I could help, but why didn't you just accept my comment as an answer?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question