我想在文件的每一行的开头添加一个特定的字符串.所以,如果我在someFile.txt中有以下两行,并想用管道添加日期字符串03/06/2012-
Hello|there|john
Hello|there|joel
Run Code Online (Sandbox Code Playgroud)
我会-
03/06/2012|Hello|there|john
03/06/2012|Hello|there|joel
Run Code Online (Sandbox Code Playgroud)
怎么实现呢?
注意我在文件中有130万行.
mik*_*iku 30
$ awk '{print "03/06/2012|" $0;}' input.txt > output.txt
Run Code Online (Sandbox Code Playgroud)
在一些普通的2010硬件上,对于具有130万行的文件大约需要0.8秒.
小智 5
sed -i 's/^/03\/06\/2012|/' input.txt
Run Code Online (Sandbox Code Playgroud)