$ and Perl's global regular expression modifier

前端 未结 3 1206
南旧
南旧 2021-01-02 21:42

I finally figured out how to append text to the end of each line in a file:

perl -pe \'s/$/addthis/\' myfile.txt

However, as I\'m trying to

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-02 22:16

    A workaround :

    perl -pe 's/\n/addthis\n/' 
    

    no need g modifier : the regex is treated line by lines.

提交回复
热议问题