Monday, April 29, 2024
57
rated 0 times [  57] [ 0]  / answers: 1 / hits: 25418  / 2 Years ago, wed, january 5, 2022, 12:50:26

I want to add hashes to all the lines in a regular text file. I'm fine with both the use of terminal and GUI—I just need to get it done.


More From » text-processing

 Answers
2

You can use sed to do that:



sed -i.bak 's/^/##/' file


This replaces the start of the line (^) with ##.



With the -i.bak switch, sed edits the file in-place, but creates a backup copy with extension.bak.


[#44056] Wednesday, January 5, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hreadsoplet

Total Points: 220
Total Questions: 108
Total Answers: 105

Location: Serbia
Member since Fri, Jun 3, 2022
2 Years ago
;