Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1095  / 2 Years ago, sat, october 15, 2022, 11:17:39

file:



sh  xyz/abc/www/def/gef/rqs/
sh xyz/toh/aaa/def/gef/rqs/
sh xyz/123/qqq/def/gef/rqs/


I want changes like this



sh  xyz/abc/www/def/gef/rqs/
#sh xyz/toh/aaa/def/gef/rqs/
sh xyz/123/qqq/def/gef/rqs/


edited: file paths to match my problem statement.


More From » sed

 Answers
5

You can use



sed -i '%xyz/toh/aaa% s/^/#/' file


Explanation:




  • % set the regex delimiter to % (so as not to conflict with the path separator /)

  • match xyz/toh/aaa

  • replace the start of line ^ by `#


[#5636] Monday, October 17, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ettorina

Total Points: 439
Total Questions: 99
Total Answers: 131

Location: Vanuatu
Member since Wed, Oct 14, 2020
4 Years ago
;