feat: Initial commit
This commit is contained in:
31
Laboratorio10/find.py
Normal file
31
Laboratorio10/find.py
Normal file
@@ -0,0 +1,31 @@
|
||||
class color:
|
||||
PURPLE = '\033[95m'
|
||||
CYAN = '\033[96m'
|
||||
DARKCYAN = '\033[36m'
|
||||
BLUE = '\033[94m'
|
||||
GREEN = '\033[92m'
|
||||
YELLOW = '\033[93m'
|
||||
RED = '\033[91m'
|
||||
BOLD = '\033[1m'
|
||||
UNDERLINE = '\033[4m'
|
||||
END = '\033[0m'
|
||||
|
||||
def main():
|
||||
files = input("Insert filenames separated by whitespaces: ").strip().split()
|
||||
|
||||
keyword = input("Insert keyword: ")
|
||||
|
||||
for file in files:
|
||||
try:
|
||||
fio = open(file, "r")
|
||||
except FileNotFoundError:
|
||||
print("File", file, "not found")
|
||||
continue
|
||||
|
||||
for line in fio:
|
||||
if keyword in line.lower():
|
||||
print(file + ":", line.removesuffix("\n").replace(keyword, color.GREEN + color.BOLD + keyword + color.END))
|
||||
|
||||
fio.close()
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user