gpt4 book ai didi

regex - Perl:将字符添加到行的开头

转载 作者:行者123 更新时间:2023-11-29 09:03:23 25 4
gpt4 key购买 nike

我想在文本文件的每一行的开头添加一个 "字符。有什么简单的解决方案吗?

最佳答案

perl -p -e 's/^/"/' myfile 应该这样做!

$ cat myfile 
0
1
2
3
4
5
6
7
8
9
10
$ perl -p -e 's/^/"/' myfile
"0
"1
"2
"3
"4
"5
"6
"7
"8
"9
"10

关于regex - Perl:将字符添加到行的开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6847443/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com