установить display_filter = "/ PATH / TO / THIS / PYTHON / FILE"
в вашем .muttrc
.
Python 3.3:
#!/usr/bin/env python3
import sys
import re
# import subprocess
from email.utils import format_datetime, parsedate_to_datetime
in_headers = True
for line in sys.stdin.readlines():
if line == "\n": in_headers = False
match = re.match(r'^Date: (.+)', line)
if not in_headers or not match:
print(line, end="")
continue
date_string = match.group(1)
# use this if you do not have python 3.3+
# converted_date = subprocess.Popen(['date','-d',date_string], stdout=subprocess.PIPE).communicate()[0].strip()
converted_date = format_datetime(parsedate_to_datetime(date_string).astimezone(tz=None))
print('Date:', converted_date)
Prueba
find. ! -writable
el comando find
devuelve una lista de archivos, -writable
filtra solo aquellos para los que tiene permiso de escritura y !
invierte el filtro.
Puede agregar -type f
si desea ignorar los directorios y otros 'archivos especiales'.
В системах, отличных от -Linux, и в системах без GNU find
, следующее, скорее всего, даст тот же результат, что и find. -type f ! -writable
, однако вторичные группы не учитываются.
myname=$( id -un )
mygroup=$( id -gn )
find. -type f '(' \
'(' -user "$myname" ! -perm -u=w ')' -o \
'(' ! -user "$myname" -group "$mygroup" ! -perm -g=w ')' -o \
'(' ! -user "$myname" ! -group "$mygroup" ! -perm -o=w ')' ')'
Четыре испытания по порядку:
Преимущество этого в том, что вы можете заменить имя другого пользователя и группу, что, я думаю, GNU find
-writable
не позволяет вам делать.
Та же команда, но с логикой, записанной в форме И:
find. -type f \
! '(' -user "$myname" -perm -u=w ')' \
! '(' ! -user "$myname" -group "$mygroup" -perm -g=w ')' \
! '(' ! -user "$myname" ! -group "$mygroup" -perm -o=w ')'