In the use of Linux, we are often increase or decrease the characters at the begin or end of line in the document, but if the document is too large, and more cumbersome manual changes, you can use sed to modify batch.
Add a character at the begin of each line
1
| sed -i 's/\(^\)/#/g' /home/test.txt #add a '#' at the begin of line |
1
| sed -i 's/\(^.\)/#/g' /home/test.txt #instead of the first character |
Delete the character of ‘#’
1
| sed -i 's/#/ /g' /home/test.txt |
Add a string at the end of line
1
| sed -i 's/\($\)/aaa/g' /home/test.txt #add a string of 'aaa' at the end of line |