#!/usr/bin/env python # import required modules: # import os import sys # decode the command line argument # print("--- decoding the command line argument ---") print("the program name is %s" % (sys.argv[0])) print("the name of the file to be processed is %s" % (sys.argv[1])) print("--- done decoding the command line argument ---") # open a file, read each line, and strip the last character on each # line, which is a line feed # print("--- reading a file ---") lines = [line.rstrip('\n') for line in open(sys.argv[1])] print("--- done reading a file ---") # print the contents as a list # print("--- printing the contents ---") print(lines) print("--- done printing ---") # print the contents line by line # print("--- printing line by line ---") counter = int(0) for line in lines: print("line no. %d: %s" % (counter, line)) counter += int(1) print("--- done printing ---") # # end of file