Compare the Permissions for all the scripts that exists in two Directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Compare the Permissions for all the scripts that exists in two Directories
# 1  
Old 12-14-2012
Compare the Permissions for all the scripts that exists in two Directories

Hello All,

I am in the process of finding the permissions on all the files that exists in two directories:

Dir1: PROD_Scripts/*
Dir2: STAGE_Scripts/*

Both the Directories have some shell and perl scripts respectively.

Step1: Finding all the Scripts that exists in PROD but Not in STAGE.
I found out Using diff Dir1 Dir2 and got 17 Scripts that exists in PROD but not in STAGE

Step2: Find out all the Scripts where the Permissions doesn't match between Dir1 and Dir2.

Could someone please help me out in doing step2

I really appreciate your time and effort!!!
# 2  
Old 12-14-2012
Code:
find PROD_scripts -type f -exec ls -l {} \; > dir1.txt
find STAGE_scripts  -type f -exec ls -l {} \; > dir2.txt
awk 'FILENAME=="dir1.txt" {arr[$(NF)]=$1}
       FILENAME=="dir2.txt" {print  $(NR), "dir1=", arr[$(NF)], "dir2=", $1}
      ' dir1.txt dir2.txt

# 3  
Old 12-15-2012
Hi Jim,

Thanks for your reply.

I am getting the following error when I am trying to execute the awk command:
Code:
$ awk 'FILENAME=="dir1.txt" {arr[$(NF)]=$1} FILENAME=="dir2.txt" {print  $(NR), "dir1=", arr[$(NF)], "dir2=", $1}' dir1.txt dir2.txt
awk: trying to access field 604
 record number 604


Cheers!

---------- Post updated 12-14-12 at 11:24 PM ---------- Previous update was 12-13-12 at 11:54 PM ----------

Hello All,

Could someone suggest any way to solve this ?

Thanks for your replies.

Last edited by filter; 12-15-2012 at 12:23 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find comand directories permissions

Hi, In the code below, while the "xarsg" command does not search in "tavi_valo" subdir? IAB00201:UG02222:EXPL> ls -1|xargs -IXX find XX -name tv_va_servbonos 2>/dev/null UG02222/fuentes/TAVA/TAVA4E0000/backup/tv_va_servbonos... (2 Replies)
Discussion started by: Jose Luis
2 Replies

2. AIX

Permissions on directories and files

Hello, I have a main directory called /test123 /test123 has lot of sub-directories and files. drwxr-x--- 21 root system 4096 Jan 25 10:20 /test123 Here, "other" does not have any access to /test123 folder. How can we provide read-only access to others on /test123... (1 Reply)
Discussion started by: aaron8667
1 Replies

3. Shell Programming and Scripting

Create duplicate directories with same permissions

Hi all, I need to create duplicate directories and sub directories (only the directories not the files or file contents) with the same permissions. Can some one guide me in doing this. I could able to create but here the permissions should be the same how can i do this in linux. Thanks in... (5 Replies)
Discussion started by: Olivia
5 Replies

4. UNIX for Dummies Questions & Answers

how to change permissions only to files, not directories....?

Hi, I am really new to unix, any help is much appreciated. I need to change permissions of all files under several subdirectories to 700 but keep directories readable (755). Why ? Because I need a FTP user to only list his files and can't read them. But to browse to subfolder, the directories... (3 Replies)
Discussion started by: narrok
3 Replies

5. Shell Programming and Scripting

checking textfile exists or not in all directories

Hai All, please help me in solving this assignment!!! i need a unix script that has to check the text file exists or not in all directories and sub directories if textfile exists display the directory path else display does not exists!! example: kamal.txt that i want to search if the... (5 Replies)
Discussion started by: G.K.K
5 Replies

6. Shell Programming and Scripting

my scripts does not check if directory exists

Hello: Can someone please help me figure out what is wrong here, my script does not move on to the "else" part even though there is no .ssh directory on my remote server: $more putkey.sh #!/bin/ksh for server in `cat list` do if ; then cat $HOME/.ssh/id_rsa.pub |ssh $server ' cat >>... (4 Replies)
Discussion started by: Sara-sh
4 Replies

7. Shell Programming and Scripting

How to check if all directories of file's path exists?

I wonder if the script below is possible to write somehow more efficiently. It seems to me the problem is very common.. CreateFolders() # parameter: name of file with relative path with regard to directory $project_root { echo $1 | awk '{ n=split($1, array, "/"); ... (2 Replies)
Discussion started by: MartyIX
2 Replies

8. Ubuntu

Newbie, Directories permissions

Basicly im trying to edit a file for apache2 in /var/etc/apache2 and i dont have permissions, my login name is associated with root but i still can't do anything, Does anyone have any ideas? Thanks in advance! (3 Replies)
Discussion started by: sypherz
3 Replies

9. Shell Programming and Scripting

File exists with Permissions

Hello All, I wrote the following script that identifies when a file is created: file1=/path/1 file2=/path/2 while true do if ]; then echo "$file1 and $file2 exist" execute SAS jobs print "Finished processing SAS files" exit 0 else sleep 300 fi done ... (2 Replies)
Discussion started by: Jose Miguel
2 Replies

10. UNIX for Dummies Questions & Answers

Permissions for Directories and Subdirectories

Is it possible to have a directory owned (by root) with permissions drwx------ and then have a sub directory of rwxrwxrwx. I know that this may be soo simple but I had no luck googling it. Thanks for your help (1 Reply)
Discussion started by: clancymf
1 Replies
Login or Register to Ask a Question