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

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 :

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

�Hola Jos� Luis! Si me lo permites me gustar�a se�alarte algunos detalles.

> 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

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.

find . -name tv_va_servbonos 2>/dev/null

There's a highlighted red dot.

Espero que te ayude.