I had to delete the first line of a file today, but I didn't want to open the file because it was close to 1 GB in size. A file this large will make most editors pretty unhappy. Instead of opening an editor to just delete a line, I used the following handy command.
mike@shiner $ sed 1d really_big_file.txt > new_file.txt
The '1d' tells sed that we want to delete line 1. The next command will delete the first three lines. The '1,3' is defining a range from line 1 to line 3.
mike@shiner $ sed 1,3d really_big_file.txt > new_file.txt
No comments:
Post a Comment