I have a Python script that inputs all words from a file and sorts them in order:
with open(raw_input("Enter a file name: ")) as f :
for t in sorted(i for line in f for i in line.split()):
print t
But instead of asking every time for the input file I would like to choose the input file with a "-i" and save the output file with a "-o", this way:
python myscript.py -i input_file.txt -o output_file.txt
and BTW, how to save the output on a target file?