Как отключить неактивные входы пользователей в Solaris?

Это было милое небольшое упражнение!

В Python я придумал следующее:

#!/usr/bin/env python3

myDict = {}

with open("file1") as f1, open("file2") as f2: 
    for line in f2: 
        (val, key) = line.split()
        myDict[key] = val 
    for line1 in f1: 
        myKey = line1.split()[4] 
        if myKey in myDict:
            print(line1.rstrip() + " " + myDict[myKey])

Результат:

./comFiles.py 
471808241 29164840 1 10001 156197396 610146
471722917 21067410 1 31001 135961856 531101
471941441 20774160 1 7001  180995072 707012
471568655 29042630 1 15001 157502996 615246
471524711 20716360 1 4001  180226817 704011
471873918 29583520 1 2001  128567298 502216
471568650 29042631 1 15002 157502910 685221

Прокомментированная версия скрипта:

#!/usr/bin/env python3

myDict = {}

# Open both files for reading
with open("file1") as f1, open("file2") as f2: 
    for line in f2: 
        # Read file2 into dictionary
        (val, key) = line.split()
        myDict[key] = val 
    for line1 in f1: 
        # Use the 5th field of file1...
        myKey = line1.split()[4] 
        if myKey in myDict: # to search for our value in our dict (file2)
            print(line1.rstrip() + " " + myDict[myKey])
3
11.09.2015, 23:38
0 ответов

Теги

Похожие вопросы