g_Dorks / sort.py
Tanvir
initialize
91e0ed2 unverified
raw
history blame contribute delete
659 Bytes
import argparse
def sort_file(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
lines.sort()
with open(file_path, 'w') as file:
file.writelines(lines)
print(f"The lines in {file_path} have been sorted.")
def main():
parser = argparse.ArgumentParser(description='Sort lines in a text file.')
parser.add_argument('file', nargs='?', help='Path to the text file to be sorted')
args = parser.parse_args()
if args.file:
file_path = args.file
else:
file_path = input("Enter the path to the text file: ")
sort_file(file_path)
if __name__ == "__main__":
main()