Getting the Folder Structure in Unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting the Folder Structure in Unix
# 1  
Old 11-03-2011
Getting the Folder Structure in Unix

Hi All,

I have a compute box and I want to tar directory structure under a directory and then Deploy/untar it in a new compute box so that the directory structure will be exactly the same.

I do not want any of the file to be extracted and deployed but instead only the directory structure.

For example:
the compute box:
Code:
xsth1256dap $ uname -a
Linux xstm3414dap 2.6.18-194.11.4.el5 #1 SMP Fri Sep 17 04:57:05 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

I have a directory called /home/filter/data and under that i have
/home/filter/data/bil , /home/filter/data/otm , ..etc

I want the directory structure "/home/filter/data" which includes all the sub-directory structure as well.

Could someone please help me sharing your ideas on this.

Really appreciate your help and time.
# 2  
Old 11-03-2011
if is installed tree package on your system maybe try this
Code:
$ tree -d /home/filter/data

# 3  
Old 11-03-2011
Try this:
Code:
tarListOfFiles="./tarFiles.txt"
tarOutputFile="./tarOutput.tar"
find /home/filter/data -type d > "${tarListOfFiles}"
# This on SunOS
tar -cvf "${tarOutputFile}" -I "${tarListOfFiles}"
# This on Linux
tar -cvf "${tarOutputFile}" -T "${tarListOfFiles}"

I hope it helps!

Last edited by felipe.vinturin; 11-03-2011 at 12:28 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to copy all structure folder create last day?

HI All, please help , i got same case . i want copy folder and directory create yesterday. for sample below : drwxr-xr-x 4 apps apps 33 Nov 23 04:00 xxxxxx@gmai.com drwxr-xr-x 4 apps apps 33 Nov 23 04:00 yyyyyyy@gmail.com drwxr-xr-x 4 apps apps 33 Nov 24 04:00... (2 Replies)
Discussion started by: fajar_3t3
2 Replies

2. Shell Programming and Scripting

Script to move files and Creation of folder structure

We are receiving few zipped files in one location say : apple/oranges/incoming All .zip files are placed here in incoming folder. So few of the files are password encrypted. There are only 10 zipped files, so we are planning to create a script which will pick that zip file from incoming... (1 Reply)
Discussion started by: Sidhant
1 Replies

3. Shell Programming and Scripting

Parallel move keeping folder structure along with files in it

The below will move all the files in the directory dir to the destination using parallel and create a log, however will not keep them in the directory. I have tried mkdir -p but that does not seem to work or at least I can not seem to get it (as it deletes others files when I use it). What is the... (2 Replies)
Discussion started by: cmccabe
2 Replies

4. Shell Programming and Scripting

Untar only folder structure from a tar ball

I have a tar file hello.tar which is 95 GB. hello.tar has many files and folders including some tar files as well. I wish to create a new tar ball which should maintain only the folder structure of hello.tar and the tar ball within the hello.tar So basically the idea is to untar... (2 Replies)
Discussion started by: mohtashims
2 Replies

5. Shell Programming and Scripting

Copying files from various folders to similar folder structure in another location

Hi, I need to write a script the has to copy the files from folders and subfolders to the same folder structure located in another location. Ex: mainfolder1 file1,file2,file3 subfolder1(file1,etc) subfolder2(file1,etc) to another folder location of same folder structure. rsync is not... (7 Replies)
Discussion started by: Raji Perumal
7 Replies

6. Shell Programming and Scripting

Move files & folder structure

Hey, this might be a really basic question, but I'm new to Unix scripting. I'm trying to find a command to replicate a file structure from one location to another & move the actual files contained in the base directories, i.e. I have this structure - home/temp/test/dir1/ ... (3 Replies)
Discussion started by: SOCLA_CELT
3 Replies

7. Shell Programming and Scripting

IMAPSYNC - trouble to create mailbox folder structure

Hi, I have installed ImapSync on Linux Debian. I tried run command to copy from Server A to Server B. It's run but imapsync doesn't create mailbox folder structure. I don't know if there is a command to force creation of mailbox's folders and subfolder. My command is below imapsync --host1... (0 Replies)
Discussion started by: symonx80
0 Replies

8. Shell Programming and Scripting

Copy a file by creating folder structure in destination as in Souce

Hello, i am having a source directory which consist of multiple sub directories and my destination folder is a empty directory. if try to copy a file source->test->1.txt from source to destination test2 using the commaind. cp source/test/1.txt desti/ It will copy the 1.txt under desti... (1 Reply)
Discussion started by: tsaravanan
1 Replies

9. Shell Programming and Scripting

Copy only folder structure ?

Hello, I am not sure how feasible is it, but trying to copy/create the folders from one box to another. I dont want to copy the content of folder otherwise it'd be too much of data.. The folder structure is quite complex (in deep hierarchy) and its a big effort manually .. Please... (5 Replies)
Discussion started by: navsha
5 Replies

10. Shell Programming and Scripting

File Management: How do I move all JPGS in a folder structure to a single folder?

This is the file structure: DESKTOP/Root of Photo Folders/Folder1qweqwasdfsd/*jpg DESKTOP/Root of Photo Folders/Folder2asdasdasd/*jpg DESKTOP/Root of Photo Folders/Folder3asdadfhgasdf/*jpg DESKTOP/Root of Photo Folders/Folder4qwetwdfsdfg/*jpg DESKTOP/Root of Photo... (4 Replies)
Discussion started by: guptaxpn
4 Replies
Login or Register to Ask a Question