Answers for "how to delete first line in file"

1

python read file delete first line

with open('file.txt', 'r') as fin:
    data = fin.read().splitlines(True)
with open('file.txt', 'w') as fout:
    fout.writelines(data[1:])
Posted by: Guest on December-02-2021
1

bash how to remove the first n lines of a file

# Example usage (3 options):
tail -n +43 input_file	# Print from the 43rd line on
sed 1,42d input_file	# Print from the 43rd line on
sed -i 1,42d input_file	# Remove the first 42 lines in place (meaning 
	# that the file is changed without having to print the output to a 
    # new file)
Posted by: Guest on September-14-2020

Code answers related to "how to delete first line in file"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language