[Solved] how to replace first line of a file using python or other tools?
Using Python 3: import argparse from sys import exit from os.path import getsize # collect command line arguments parser = argparse.ArgumentParser() parser.add_argument(‘-p’, ‘–parameter’, required=True, type=str) parser.add_argument(‘-f’, ‘–file’, required=True, type=str) args = parser.parse_args() # check if file is empty if getsize(args.file) == 0: print(‘Error: %s is empty’ % args.file) exit(1) # collect all lines first lines … Read more