When you browse a technical blog, you will findCodeThere is a row number, just like the following code:
1 void main ()
2 {
3 printf ("hello ");
4}
If this happens in the blog, you can also copy the row number without copying it (if the row is selected correctly), but other websites may not. To remove the line numbers when copying code, I wrote a script to remove these annoying lines. First, paste the code for you to see:
#! /Bin/bash
WhileRead line
Do
Num = 'echo"$ Line"| Awk'{Print $1}'`
Lennum =$ {# num}
Lenline =$ {# Line}
Echo"$ {Line: $ lennum: $ lenline-$ lennum}"
# Echo $ line
Done
Is it clear? Save the above Code to the denu. Sh file and add executable permissions to denu. Sh. The principle is to remove the first word in each line. The usage is as follows:
The hypothetical code.cpp.txt is the code with a line number copied from the Internet. You can use the following command to remove the line number:
Cat code.cpp.txt |./denu. Sh> code. cpp
The final code. cpp is the final file, but it may not be indented...