Count line in files search for necessary command cat file txt wc -l Ou

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
1.Count line in files (search for necessary command)
cat ~/file.txt | wc -l
2.Output of time command:
real or total is the time from start to finish of the programm.
user - amount of CPU time spent in user mode.
system or sys - amount of CPU time spent in kernel mode.
3. There is a file with logs, get list of ding ids that appear in this file and write to .txt file
path = '/Users/mark/Desktop/delete_many_one_05_08_2019.csv'
output = '/Users/mark/Desktop/result'
with open(path, 'r') as f:
data = f.readlines()
with open(output + ".txt" , 'w') as f:
for line in data:
if "ding_id" in line:
result = line.split('""ding_id"":')[1].split(',')[0].strip('""') +'\n'
f.write(result)
4. get list mac,ding_id and write into csv file
path = '/Users/mark/Desktop/delete_many_one_05_08_2019.csv'
output = '/Users/mark/Desktop/result'
with open(path, 'r') as f:
data = f.readlines()
with open(output + ".csv" , 'w') as f:
for line in data:
if "ding_id" in line:
result = str([line.split('""device_id"":')[1].split(',')[0].strip('""}'), line.split('""ding_id"":')[1].split(',')[0].strip('""""')]) + '\n'
f.write(result)