Portál AbcLinuxu, 4. listopadu 2025 19:06
grep -e "[^:]*:[^:]*:[^:]*:[^:]*:[^ ]* [^ ]* [^:]*" /etc/passwd
egrep -e "([^:]*:){4}([^ ]* ){2}[^ ]*:" /etc/passwd
echo "sarka:x:552:1002:Laurent Steveny:/home/sar\ ka:/bin/bash" |
egrep -e "([^:]*:){4}([^ ]* ){2}[^ ]*:"
echo "sarka:x:552:1002:Lau rent Stev eny:/home/sarka:/bin/bash" |
egrep -e "([^:]*:){4}([^ ]* ){2}[^ ]*:"To jsou namátkou dvě chyby jen tak z hlavy. Já bych doporučil spíš egrep -e "([^:]*:){4}([^ :]* ){2}[^:]+:"To by zadání mělo odpovídat mnohem víc.
#!/usr/bin/python
import pwd
for user in pwd.getpwall():
name = user.pw_gecos
if len(name.split()) < 3: continue
print name
Výstup:
virtual console memory owner Portmapper RPC user RPC Service User Anonymous NFS User System message bus X Font Server Canna Service User Wnn System Account GNU Mailing List Manager Network Crash Dump user Quagga routing suite mgetty fax spool user Network UPS Tools User for Beagle indexingAni jsem netušil, že těch "uživatelů" bude tolik
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.