Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to rsync or tar directory trees, with hidden directory, but without files? Post 302454642 by drl on Sunday 19th of September 2010 12:54:42 PM
Old 09-19-2010
Hi.

I found it easier to think of replicating the directory tree, omitting the non-directory items, and then tarring up that tree:
Code:
#!/usr/bin/env bash

# @(#) s1	Demonstrate replication of directory structure.

# Utility functions: print-as-echo, print-line-with-visual-space.
pe() { for i;do printf "%s" "$i";done; printf "\n"; }
pl() { pe;pe "-----" ;pe "$*"; }

pl " Original tree \"a\" with files:"
tree -a -F a

pl " Original tree \"a\", listing directories only:"
tree -d -a -F a

rm -rf skeleton skeleton-t1
find . -type d ! -name '*skeleton*' > skeleton-t1
# cat skeleton-t1
sed 's|^[.]|skeleton|' skeleton-t1 > skeleton-t2
# cat skeleton-t2

IFS=$'\012'
while read dir
do
  mkdir "$dir"
done < skeleton-t2

pl " New upper tree named \"skeleton\", same structure, expecting no files:"
tree -a -F skeleton

pl  " Final tar operation:"
tar cvf skeleton.tar -C skeleton .

pl " Listing of tar file:"
tar xvf skeleton.tar

exit 0

producing on an existing example tree "a":
Code:
% ./s1

-----
 Original tree "a" with files:
a
|-- .a4
|-- a-3
|-- a1
|-- a2
|-- b/
|   |-- b1
|   |-- b2
|   |-- b3 with spaces
|   `-- d/
|       |-- d1
|       `-- d2
`-- c/
    |-- c1
    |-- c2
    `-- e-dir with spaces/
        |-- .f-hidden/
        |   |-- f1
        |   `-- f2
        |-- e1
        `-- e2

5 directories, 15 files

-----
 Original tree "a", listing directories only:
a
|-- b
|   `-- d
`-- c
    `-- e-dir with spaces
        `-- .f-hidden

5 directories

-----
 New upper tree named "skeleton", same structure, expecting no files:
skeleton
`-- a/
    |-- b/
    |   `-- d/
    `-- c/
        `-- e-dir with spaces/
            `-- .f-hidden/

6 directories, 0 files

-----
 Final tar operation:
./
./a/
./a/b/
./a/b/d/
./a/c/
./a/c/e-dir with spaces/
./a/c/e-dir with spaces/.f-hidden/

-----
 Listing of tar file:
./
./a/
./a/b/
./a/b/d/
./a/c/
./a/c/e-dir with spaces/
./a/c/e-dir with spaces/.f-hidden/

I ran this on a tree that had 60 MB in 280 directories, and it went too quickly for me to see anything except the last part of the list.

There may be other shorter methods as well ... cheers, drl
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

rsync: taking advantage of files in different directory other than destination

Dear Folks, I have to backup pgsql database dump everynight on a routine. The database dump actually contains sql(text) statements. The actual size of the database dump is aroung 800 MB. Between two days backup, only few lines of statements are modified/added/deleted. I dont want to do... (1 Reply)
Discussion started by: rssrik
1 Replies

2. Shell Programming and Scripting

Best way to diff two huge directory trees

Hi I have a job that will be running nightly incremental backsup of a large directory tree. I did the initial backup, now I want to write a script to verify that all the files were transferred correctly. I did something like this which works in principle on small trees: diff -r -q... (6 Replies)
Discussion started by: same1290
6 Replies

3. UNIX for Dummies Questions & Answers

tar files in directory

can someone give me a script to tar files that is older than 5 days in a directory that is not something like this: fileArray=($(find -mtime +5 asdfasdf)) tar -cvf asfadfasdfa ${fileArray} as the Unix I'm using has some problem with ($( )), I need another way to tar files in the folder.... (1 Reply)
Discussion started by: s3270226
1 Replies

4. Shell Programming and Scripting

How to copy very large directory trees

I have constant trouble with XCOPY/s for multi-gigabyte transfers. I need a utility like XCOPY/S that remembers where it left off if I reboot. Is there such a utility? How about a free utility (free as in free beer)? How about an md5sum sanity check too? I posted the above query in another... (3 Replies)
Discussion started by: siegfried
3 Replies

5. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

6. Shell Programming and Scripting

Rsync to copy specific subfolders and files to new directory

RootFolderI: RootFolderI/FolderA/Subfolder1/Subsub1/JPG1.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/Subsub1/JPG2.jpg -> want this jpg RootFolderI/FolderA/Subfolder2/Subsub2/JPG3.jpg . . . RootFolderI/FolderB/Subfolder1/Subsub1/JPG4.jpg -> want this jpg ... (1 Reply)
Discussion started by: blocnt
1 Replies

7. Shell Programming and Scripting

ksh - Checking directory trees containing wild cards

Hi Can somebody please show me how to check from within a KSH script if a directory exists on that same host when parts of the directory tree are unknown? If these wildcard dirs were the only dirs at that level then ... RETCODE=$(ls -l /u01/app/oracle/local/*/* | grep target_dir) ... will... (4 Replies)
Discussion started by: user052009
4 Replies

8. Shell Programming and Scripting

Rsync - how to copy hidden folder or hidden files when using full path

Hello. I use this command : rsync -av --include=".*" --dry-run "$A_FULL_PATH_S" "$A_FULL_PATH_D"The data comes from the output of a find command. And no full source directories are in use, only some files. Source example... (2 Replies)
Discussion started by: jcdole
2 Replies
icmstart(1)						starts icmbuild program maintenance					       icmstart(1)

NAME
icmstart - A startup script for icmbuild program maintenance SYNOPSIS
icmstart [Options] top-dir [program|library] DESCRIPTION
The icmstart script is a generic script that can be used to start program maintenance using icmake(1) and icmbuild(1). Icmstart creates an initial directory top-dir and installs the files CLASSES, VERSION and icmconf below top-dir. A second argument `program' or `library' may be specified as the default mode of operation of the icmbuild(1) script. Skeleton files for the main directory and subdirectories, by default listed in the file /etc/icmake/icmstart.rc, may be installed as well (cf. icmstart.rc(7)). After changing to the directory created by icmstart the icmbuild(1) script may be used for program maintenance. OPTIONS
Icmstart may be called with the following options, which (if specified) must be the first arguments of icmstart: o -c confpath Use the configuration files (icmstart.rc, AUTHOR, YEARS and VERSION) if found in `confpath' rather than in ~/.icmake and/or /etc/icmake/. Once a file is found it is used allowing partial overrides of the default files provided by icmake(1). o -d Do not execute any commands, but show the commands that would have been executed on the standard output. o -I Do not install files. o -r Unconditionally replace existing files. If -r is not provided icmstart will ask the user to confirm that an existing file must be overwritten. If a skeleton specification refers to a directory, the full directory and its subdirectories will be replaced. o -s skeleton-path By default skeleton files are listed in the skeleton resource file /usr/share/icmake/icmstart.rc. Alternatively, the skeleton resource file may be specified by the ICM environment variable, which -in turn- may be overruled by the path specified with the -s option. The skeleton path may be specified as a full file-path or as a directory, in which case the skeleton resource file is assumed to be icmstart.rc (see below at SKELETON FILES). Since icmstart uses cp to install files, cp must be available when icm- start should install skeleton files. SKELETON FILES
Skeleton resource files may contain comment (empty lines and lines beginning with the hash-mark (#)) which is ignored, and should otherwise contain specifications of resource s to install. The default resource file is /etc/icmake/icmstart.rc, contains CLASSES P main.cc P main.ih P usage.cc P version.cc P ? scanner P ? parser This file is overruled by ~/.icmake/icmstart.rc. See icmstart.rc(7) for details about the format of the icmstart.rc file. CONFIGURATION FILES
The configuration files icmstart.rc, AUTHOR, YEARS and VERSION are recognized and processed by icmstart. If the -c option was specified configuration files found in the path specified at this option are used. If not specified or if a file isn't found then the path ~/icmake is inspected. If a configuration file isn't found in ~/icmake either, configuration files in /etc/icmake are used. Configuration files are not required for the proper operation of icmstart. When absent icmstart performs the following default actions: o If the file AUTHOR does not exist icmstart uses #define AUTHOR "". When the file AUTHOR is defined in a configuration path it should have one line, defining the author of the program. E.g., #define AUTHOR "Frank B. Brokken <f.b.brokken@rug.nl>" o If the file VERSION does not exist icmstart uses #define VERSION "0.00.00". When the file VERSION is defined in a configuration path it should have one line, defining the program's initial version. E.g., #define VERSION "1.00.00" o If the file YEAR does not exist icmstart uses #define YEARS "yyyy" where yyyy is the current year. When the file YEAR is defined in a configuration path it should have one line, defining the program's initial release year. E.g., #define YEARS "2012" Plural is used here since a release year usually becomes a range of years after some time, as with Icmake's years specification: #define YEARS "1992-2012" o If the file icmstart.rc does not exist (or is empty) icmstart will not install any of the files normally found in icmstart.rc, but the initial project directory, icmconf and VERSION are installed. ) FILES
The mentioned paths are sugestive only and may be installation dependent: o /usr/share/icmake/icmconf Example of a icmbuild configuration file; o /usr/share/icmake/CLASSES Example of a icmbuild CLASSES file. o /usr/share/icmake/icmstart.rc Default skeleton resource file. SEE ALSO
icmake(1), icmbuild(1), icmconf(7), icmstart.rc(7). BUGS
None reported COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). icmake.7.18.00.tar.gz 1992-2012 icmstart(1)
All times are GMT -4. The time now is 08:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy