Benutzer-Werkzeuge

Webseiten-Werkzeuge


shelltricks

Dies ist eine alte Version des Dokuments!


Shelltricks

Miscellaneous small shell scripts that I may or may not need again in the far future.

Check umask for all users

check_user_umasks.sh
#!/bin/bash
 
for user in $(awk -F: '{print $1}' /etc/passwd); do
    printf "%-20s" "$user" ; su -s /bin/bash -c 'umask' -l $user 2>/dev/null
done

Original source: https://unix.stackexchange.com/a/82645

Show the dates of the oldest unseen messages in multiple maildirs, newest first

Beware of weird directory names. I am not responsible if this somehow does an rm -rf –no-preserve-root / or something.

for dir in /var/vmail/domain/*/Maildir/new /var/vmail/domain/*/Maildir/.*/new; do
    echo -e "$(stat -c %y $dir/$(ls -Art $dir | head -1))\t$dir"
done | grep -v '/\./' | sort -rn

Same thing, but for the newest seen messages:

for dir in /var/vmail/domain/*/Maildir/cur /var/vmail/domain/*/Maildir/.*/cur; do
    echo -e "$(stat -c %y $dir/$(ls -At $dir | head -1))\t$dir"
done | grep -v '/\./' | sort -rn

The only differences are the folders (cur vs. new) and the sorting done by ls.

shelltricks.1620924654.txt.gz · Zuletzt geändert: 2021-05-13 18:50 von fanir