Find comand directories permissions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find comand directories permissions
# 1  
Old 01-26-2016
Find comand directories permissions

Hi,


In the code below, while the "xarsg" command does not search in
"tavi_valo" subdir?


Code:
IAB00201:UG02222:EXPL> ls -1|xargs -IXX find XX -name tv_va_servbonos 2>/dev/null
UG02222/fuentes/TAVA/TAVA4E0000/backup/tv_va_servbonos
UG02222/fuentes/TAVA/TAVA4E0000/pendiente/va/tv_va_servbonos
UG02222/fuentes/TAVA/TAVA4O0000/bin/tv_va_servbonos
es/tvva/tuxedo/bin/tv_va_servbonos
IAB00201:UG02222:EXPL>
IAB00201:UG02222:EXPL> for dir in $(ls -1)
> do
> find $dir -name tv_va_servbonos 2>/dev/null
> done
UG02222/fuentes/TAVA/TAVA4E0000/backup/tv_va_servbonos
UG02222/fuentes/TAVA/TAVA4E0000/pendiente/va/tv_va_servbonos
UG02222/fuentes/TAVA/TAVA4O0000/bin/tv_va_servbonos
es/tvva/tuxedo/bin/tv_va_servbonos
tari_valo/valoracion/bin/tv_va_servbonos
tari_valo/valoracion/binseg/tv_va_servbonos
tari_valo/acep_plan/valoracion/tux/PTAVA230000/tv_va_servbonos
tari_valo/explotacion/his/PTAVA230000_1/tv_va_servbonos
tari_valo/explotacion/his/PTAVA160000_1/tv_va_servbonos
tari_valo/explotacion/his/PTAVA230000_TAVA280000_TAVA260000_TAVA300000_TAVA270000/tv_va_servbonos
IAB00201:UG02222:EXPL> ll -d . *
drwxr-xr-x  26 root     system         1024 Nov 28 2014  .
drwxr-xr-x   4 UG00000  aplic          1024 Sep 08 2006  UG00000
drwxr-xr-x  37 UG02222  aplic          4096 Jan 26 18:22 UG02222
drwxr-xr-x   3 2608     111              96 Nov 28 2014  cota
drwxr-xr-x   3 root     system           96 Feb 16 2005  ctm
drwxr-xr-x   4 dbtvva   dba              96 Apr 06 2005  datos
drwxr-xr-x  36 dbtvva   dba            1024 Jul 29 2014  datos_tvva
drwxr-xr-x   3 root     system           96 Apr 06 2005  es
drwxr-xr-x  23 dbtvva   dba            1024 Jul 29 2014  indices_tvva
drwxr-xr-x   2 root     system           96 Jan 25 23:00 lost+found
drwxrwxrwx   9 6663     504       321840128 Jan 26 18:41 nfs_aing
drwxr-x---   2 root     system           96 Jun 28 2012  nfs_aing_tmp
drwxrwxrwx   4 UG02222  tava           1024 Mar 06 2013  nfsiab00201
drwxr-xr-x   4 UG02222  aplic            96 Jul 11 2005  nfsiab00201_old
drwxr-xr-x  15 root     bin            1024 Dec 11 23:00 openv
drwxr-xr-x  20 dbtvva   dba            1024 Jul 10 2012  oracle
drwxr-xr-x   2 root     sys              96 Feb 16 2005  patrol
drwxr-xr-x   7 pcms     pcmsdba        1024 May 24 2005  pcms
drwxr-xr-x   3 UG00000  repl             96 Apr 06 2005  replica
drwxrwxrwx   2 usbtava  tava             96 Jul 29 2014  sota
drwxr-xr-x   3 root     system           96 May 04 2005  spazio
drwxr-xr-x  20 UG02222  tava           1024 Jun 17 2014  tari_valo
drwxr-xr-x 736 ust0001  tuxedo        16384 Jan 18 11:58 users
drwxr-xr-x   3 root     system           96 Apr 11 2005  usr0001
drwxr-xr-x   5 USS0080  dba              96 Feb 02 2007  vi3
IAB00201:UG02222:EXPL> id
uid=206(UG02222) gid=201(tava) groups=206(aplic)


Thanks in advance,
Jose Luis
# 2  
Old 01-26-2016
I can't find an immediate and obvious reason for that behaviour. Please remove the 2>/dev/null so we might get a hint on a possible problem. man xargs:
Quote:
If any invocation of the command exits with a status of 255, xargs will stop immediately without reading any further input. An error message is issued on stderr when this happens.
---------- Post updated at 19:08 ---------- Previous update was at 19:06 ----------

drwxr-x--- 2 root system 96 Jun 28 2012 nfs_aing_tmp might give a problem as it won't be accessible to UG92222:tava.
# 3  
Old 01-26-2016
¡Hola José Luis! Si me lo permites me gustaría señalarte algunos detalles.

Code:
> for dir in $(ls -1)
> do
> find $dir -name tv_va_servbonos 2>/dev/null
> done

ls -1 is never of good use in a for loop, the same can be achieved by shell expansion as
Code:
for dir in *; do
    if [[ -d "$dir" ]]; then
        # do something there with "$dir"
    fi
done

The if checks that the variable $dir has an existing directory. ls -1 will send a list of files as well, which it will not do if passed to the find command. Variables should be "quoted" when passed to another commands. Inside a if [[ ]] is not necessary because of the double [[ ]] but I chose to do so, since it doesn't harm. Inside a single if [ ] you should do quote.


The find command can do recursively by itself what you are trying to do in the for loop.
Code:
find . -name tv_va_servbonos 2>/dev/null

There's a highlighted red dot.

Espero que te ayude.

Last edited by Aia; 01-27-2016 at 12:28 AM.. Reason: red dot
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Find only files/directories with different permissions/owners

My git post-update has the following lines in it to make sure the permissions are set right: find /usr/local/apache/htdocs -type d -print0 | xargs -0 chmod 755 find /usr/local/apache/htdocs -type f -print0 | xargs -0 chmod 644 chown -R apache:apache /usr/local/apache/htdocsThe only problem is... (5 Replies)
Discussion started by: dheian
5 Replies

3. Shell Programming and Scripting

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.... (2 Replies)
Discussion started by: filter
2 Replies

4. UNIX for Dummies Questions & Answers

Using grep command to find the pattern of text in all directories and sub-directories.

Hi all, Using grep command, i want to find the pattern of text in all directories and sub-directories. e.g: if i want to search for a pattern named "parmeter", i used the command grep -i "param" ../* is this correct? (1 Reply)
Discussion started by: vinothrajan55
1 Replies

5. 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

6. Solaris

find and sed comand for Solaris 9

Hi, I'm looking to combine the two commands find and sed together for the work that i'm worknig on. I need to find the ip addresse in any file from current directory and below, once is found i need to replace it with new ip addresse. Here is what i have but not complete. Find IP from... (4 Replies)
Discussion started by: lamoul
4 Replies

7. 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

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

Need help in changing Permissions to 775 for files and directories

Hi All I need to create a script which would change Permissions to 775 All the Files and directories will be mentioned in the Paramter files Can anyone give a Hint how to proceed in this ?? THanks (1 Reply)
Discussion started by: ranga27
1 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