Is it possible to delete all lines that have the same first 30 characters of the line and then only to left the first line that has these characters?
Example:
xx2 Lorem ipsum dolor sit amet, fdsfdsfs
xx2 Lorem ipsum dolor sit amet, 43434343
The second should be deleted… Hope it’s possible… Thanks
If you need to deal with really large files, reading only one line at a time and writing to a temp file will consume less memory. Using a temp file and renaming it to the input file when done will do the operation atomically without losing your original file. Checking for array keys instead of values will offer fast lookup since keys are indexed. You also need to handle the edge case of a blank line returning
falseonsubstr.