Wednesday, February 24, 2021

search a pattern in file using Python

 import re

pattern = re.compile("ORA-")

for line in open("x2.txt"):

    for match in re.finditer(pattern, line):

        print(line)


count number of files generated per day

 # count number of files generated per day

find . -type f -printf '%TY-%Tm-%Td\n' | sort | uniq -c


# count number of files generated per hour in last 600 minutes

find . -cmin -600  -type f -printf '%TY-%Tm-%Td-%TH\n' | sort | uniq -c


find . -maxdepth 1 -type f -printf '%TY-%Tm-%Td\n' | awk '{array[$0]+=1}END{ for(val in array) print val" "array[val]   }'|sort