Folders and Files Inventory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Folders and Files Inventory
# 1  
Old 03-05-2012
Folders and Files Inventory

Hi ,

We are migrating our scripts from one unix server to another unix server in aix. Is there any way we can export the permissions, owner, group of the folders and files inside the folders.

If I am copying xyz folder from old server, I need to generate a report with permissions ,owner and group for all the folders and files under xyz, same script I have to execute it in new server and compare.

Is there any utility for do this.

Regards,
Shruthi
# 2  
Old 03-05-2012
you can try something like below in awk or sed

This is not the correct syntax..just for giving you an idea.

ls -lstr | awk 'print $2,$3...(which all feilds you want) > file.csv comma separated file

run the same script in another box..
# 3  
Old 03-05-2012
If you want a quick way to check, dump all the ls -lh output into a file on each server and cksum the resulting files. If there is a difference, you could diff them to see where the differences are.
Edited to add: You need to filter out the date and time columns using awk as suggested above for this to work properly.

What are you using to migrate everything? You might look at rsync, it keeps all permissions etc intact during a move.

Last edited by spynappels; 03-05-2012 at 11:59 AM..
# 4  
Old 03-05-2012
In addition to owner and group name, will each user retain their original numeric UID and GID - or are they different on the new computer?

What software do you have available to copy the files?
# 5  
Old 03-05-2012
Hi ,

I am using the below script for generating my report...it is generating duplicate entries , and I am not able to capture owner and user info...pls tell what is wrong in the script.

Code:
!/usr/bin/

# directories
dirs=$(find . -type d | sed "s/^.\///")

nowdir=$PWD
# filelist / dir
echo "$dirs" | while read dir
do
        cd "$nowdir/$dir"
        files=$(find . -type f | sed "s/^.\///")
        echo "$files" | while read file
        do
                echo "$dir;$file"
        done
done

Regards,
Shruthi
# 6  
Old 03-06-2012
Difficult to guess what your output should look like.
I guess you mean something like this (untested on AIX - may need adjustment):
Code:
find . -print|sort| while read F
do
          ls -lad "${F}"|tr -s " "|cut -d" " -f1-5,9-
done

The idea is to do a directory listing on each file or directory but miss out the file timestamp fields. The "sort" is needed because you can't guarantee that "find" will descend the old and new trees in the same order.

If you redirect the output of the script to a file you can copy that file and the script to you new server, run the script again on your new server and compare the output. Expect to get some subtle differences (like the size of directory files).

Personally I'd make every effort to preserve the timestamps of the files and compare those too. You can't preserve the timestamps of directories by any easy method.

Last edited by methyl; 03-06-2012 at 03:18 PM..
This User Gave Thanks to methyl For This Post:
 
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 files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies

2. Shell Programming and Scripting

Match files between two folders

I have two folders: FOLDER1 file_101_1010.txt file_102_1007.txt file_103_1003.txt file_104_1007.txt file_105_1011.txt file_106_1006.txt file_108_1007.txt file_109_1002.txt file_110_1006.txt file_111_1008.txt file_112_1011.txt file_113_1012.txt file_114_1001.txt file_115_1009.txt... (5 Replies)
Discussion started by: alex2005
5 Replies

3. Shell Programming and Scripting

List all the files in the present path and Folders and subfolders files also

Hi, I need a script/command to list out all the files in current path and also the files in folder and subfolders. Ex: My files are like below $ ls -lrt total 8 -rw-r--r-- 1 abc users 419 May 25 10:27 abcd.xml drwxr-xr-x 3 abc users 4096 May 25 10:28 TEST $ Under TEST, there are... (2 Replies)
Discussion started by: divya bandipotu
2 Replies

4. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

5. Shell Programming and Scripting

Compare 2 folders to find several missing files among huge amounts of files.

Hi, all: I've got two folders, say, "folder1" and "folder2". Under each, there are thousands of files. It's quite obvious that there are some files missing in each. I just would like to find them. I believe this can be done by "diff" command. However, if I change the above question a... (1 Reply)
Discussion started by: jiapei100
1 Replies

6. Shell Programming and Scripting

Move files to Folders

Hi Friends, Below is my requirement and i am not clear how to approach this issue in unix programming. I have a folder with 2500 files. The files are in below format. 1234_name1.txt 1234_name123.txt 4567_name1.txt 4567_name123.txt and i need a program which will read each file from this... (5 Replies)
Discussion started by: diva_thilak
5 Replies

7. UNIX for Dummies Questions & Answers

Move folders containing certain files

Hello, How can I move just the folders that contains files modified n days ago? Source tree: |-- SourceFolder | |-- Subfolder1 | | |-- file1.dat | | `-- file2.dat | |-- Subfolder2 | | |-- filea.dat | | `-- fileb.dat Destination tree: |-- ... (3 Replies)
Discussion started by: xavix
3 Replies

8. HP-UX

to get the timestamp of files from the files and folders in Unix

Hi, I had a directory and many subdirectories and files with in it. Now i want to get the timestamp of files from the files and folders recursively. :( Please help me to generate a script fort he above mentioned requirement! Appreciate for ur qick response Thanks in advance! ... (2 Replies)
Discussion started by: kishan
2 Replies

9. Shell Programming and Scripting

removing old files except configuration files and folders

Dear all, I want to remove files older than 2 months in the /home/member directory. But except the configuration files (like .bash_profile .config/ .openoffice/ .local/ .kde/ etc..) I have tried with the command find . -mtime +60 -wholename './.*' -prune -o -print -exec mv {} \; but it... (1 Reply)
Discussion started by: jamcalicut
1 Replies

10. UNIX for Dummies Questions & Answers

How to Differentiate Between Files and Folders?

Hi All, I'm a rookie using HPUX and I know this is going to sound like a bonehead question, but when I list the contents of a directory, how can I determine which objects are files and which are folders? I'm using the ll and ls commands to lists the contents. So far I've been determining the... (6 Replies)
Discussion started by: dgower2
6 Replies
Login or Register to Ask a Question