@Jose-Emilio-Osorio said:
@Scott-Sumner Use the mouse is good. But, I have more than 85000 lines in a file and it´s hard to drag the line to the last line. Any method to do this ?. Thanks for your help.
If it’s a one-shot deal then use two search/replaces in regular expression mode (Ctrl-G in the search/replace box)
Search for: ^
Replace with: 00000000
If you have leading spaces then use search for: ^ *
That’ll put eight zeroes at the front of all lines
The second search/replace is:
Search for: ^[0]+([0-9]{8})$
Replace with: \1
That skips over excess leading zeroes, saves the last eight digits, and the replace part is the saved value.
Now do one more pass which is to search for ^0{8}
This searches for lines that start with eight zeroes.
If you find any then either
There were blank lines in the file and we now have 00000000 there. That may or may not be desirable
One of the lines had a number with 9 or more digits and will now have something like 00000000123456789
One of the lines had something other than a number and now has 00000000~whatever was on the line~
If you need to do this a lot then use sed. Google for GNU sed. It’s free. In sed the search/replaces would look like this
sed -r -e "s/^/00000000/" -e "s/^0+([0-9]{8})$/\1/" input-file.txt >output-file.txt
Then to check for errors
sed -r -n -e "/^0{8}/ { = ; p }" output-file.txt
This scans and for every line found that starts with eight zeroes it outputs the line number and then the offending line.