skip to Main Content

I have a need to pass a script to a perl script to run in some directories in linux (ubuntu) with bash –version
GNU bash, versión 4.4.20(1)-release (x86_64-redhat-linux-gnu)

These directories have a problem, and that is that they have extended characters including spaces, and local language characters.

IFS=$'n'
for dir in $(ls -1ld  /home/setdart/mail/setdart.com/albertit/{.,?}*/ | tr 'n' '' | xargs -0 -n 1 basename); do echo "$dir"; done > albertit.txt

Which gives me

.Archive
cur
.Drafts
.Junk
.My Folders
.My Folders.Clients
.My Folders.Cuentas
.My Folders.Enric
.My Folders.Google
.My Folders.Prove&AO8-dors
.My Folders.Prove&AO8-dors.Abdul
.My Folders.Prove&AO8-dors.Abdul.Dominis
.My Folders.Prove&AO8-dors.Datax
.My Folders.Prove&AO8-dors.DeepL
.My Folders.Prove&AO8-dors.Gerard Cuenca
.My Folders.Prove&AO8-dors.Lloguer iMacs
.My Folders.Prove&AO8-dors.Movistar - Mabel Serrano
.My Folders.Prove&AO8-dors.Vadim
.My Folders.Prove&AO8-dors.Xavi Navarro
.My Folders.Scott
.My Folders.Scott.20220224 Errores facturas pdf
.My Folders.Setdart
.My Folders.Setdart.Admin y Conta
.My Folders.Setdart.Admin y Conta.202203 Quotation errors
.My Folders.Setdart.Ident Clientes
.My Folders.Setdart.Log&AO0-stica
.My Folders.Setdart.Lotes entregados no pagados
.My Folders.Setdart.M Pal&AOg-s
.My Folders.Setdart.Madrid
.My Folders.Setdart.Ramon
.My Folders.Setdart.Tasaciones
.My Folders.Software
.My Folders.Spam etc
.My Folders.Tests
.My Folders.Tests.E-mails Setdart
.My Folders.Tests.Reclamaciones
.My Folders.Tests.Reclamaciones.V1
.My Folders.Tests.Reclamaciones.V2
.My Folders.Tests.Recuperar codi d'usuari i contrasenya
.My Folders.Tests.Recuperar codi d'usuari i contrasenya.V1
.My Folders.Tests.Recuperar codi d'usuari i contrasenya.V2
.My Folders.Todoist
.My Folders.TPV
.My Folders.Varis
.My Folders.Web
new
.Sent
.spam
tmp
.Trash

Files containing &AO8, &AO0- are not processed by the second command, they are actually extended characters of the language

for file in $(cat albertit.txt); do echo "$file"; tools/maildir-size-fix.pl -a -f -c -r $file; done

I can’t find a solution and I have more than 100 users in whom I have to pass the script and all of them, being Catalan, use Catalan as the language to name their folders.

I don’t know how to proceed to do it.

2

Answers


  1. I could see something along:

    printf "%s" /home/setdart/mail/setdart.com/albertit/{.,?}*/ | xargs -0 basename -z -a > albertit.txt
    

    Or I think just:

    find /home/setdart/mail/setdart.com/albertit/ -maxdepth 1 -mindepth 1 -type d -printf "%f" > albertit.txt
    

    And then:

    while IFS= read -r -d '' file; do
       echo "$file"
       tools/maildir-size-fix.pl -a -f -c -r "$file"
    done < albertit.txt
    

    But then just:

    xargs -0 -n 1 tools/maildir-size-fix.pl -a -f -c -r < albertit.txt
    
    Login or Signup to reply.
  2. Generally, the simple construct of

    for dir in /home/setdart/mail/setdart.com/albertit/{.,?}*/
    do tools/maildir-size-fix.pl -a -f -c -r "$dir"
    done
    

    really should work, even with odd characters.
    Does it not? Did you quote it?

    If it doesn’t, what does it do?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search