how to add increase number every end line ?
study
fly
run
swim
learning
todo
noto become
study20978
fly20979
run20980
swim20981
learning20982
todo20983
no20984 2 2 Answers
I am Notepad++ user but I would use free AWK tool for this because it is lean and effective.
AWK solution (just download awk.exe and run the following command line)
awk "BEGIN { c = 20978 } { print $0 c++ }" input.txt > output.txtResult:
study20978
fly20979
run20980
swim20981
learning20982
todo20983
no20984Downloading:
you do not even need to install the tool, just download and unpack binaries.zip and EXE is located in gawk-3.1.6-1-bin.zip\bin\awk.exe.
What the instructions do:
BEGIN { c = 20978 }we initializedcto20978.BEGINsection runs only once.- section
{ print $0 c++ }runs once for each line: we print that line (it is stored in$0) and the value of our counterc(which we immediately increase:c++)
Making it reusable:
If you would like to keep the source code for future use, put it to file numbering.awk with some nicer formatting:
BEGIN { c = 20978 }
{ print $0 c++ }And use modified command line referring to that source file:
awk -f numbering.awk input.txt > output.txtYou can save this command into numbering.bat file so you won't need to rememeber it.
Additional explanation:
For your information, less cryptic form of the source would say:
# this section runs once at the beginning
BEGIN { c = 20978 } # initialization of the counter "c"
# this section runs once for each line
{ print $0 c; # print original line followed by value of counter "c" c = c + 1; # assign value of calculation "c + 1" into "c"
} 3 Add some spaces to the last time so that the line becomes the longest.
Hold Alt+Shift then hit Up Arrows to select an area up to the top of the text.
Keep holding Alt+Shift then hit Right Arrows to adjust the area so that the cursors are at the end of the lines.
Hit Alt+C to invoke the Column Editor to add sequence numbers.
Hit Ctrl+H to replace the regular expression
\ +([0-9]+)$with$1Done!