使用cygwin工具合并两个文件
我有一个制表符分隔的文件(file1.txt),有两列,还有一个文件(file2.txt),有一长串文本。 我想用 file1 中的列值替换 file2 中的特定字符。
示例:
file1.txt
text1 text11
text2 text22
text3 text33
file2.txt
I want to insert text here:$1 and the other text here: $2
所需结果:
I want to insert text here:text1 and the other text here: text11
I want to insert text here:text2 and the other text here: text22
I want to insert text here:text3 and the other text here: text33
如何使用 cygwin 工具完成此操作?
I have one tab separated file (file1.txt) with two columns and one file (file2.txt) with a long string of text.
I want to replace specific characters in file2 with the column values in file1.
An example:
file1.txt
text1 text11
text2 text22
text3 text33
file2.txt
I want to insert text here:$1 and the other text here: $2
The desired result:
I want to insert text here:text1 and the other text here: text11
I want to insert text here:text2 and the other text here: text22
I want to insert text here:text3 and the other text here: text33
How do I accomplish this with cygwin tools?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我知道如何用 sed 来做到这一点。
sed 's/([^\t]) (.)/我想在此处插入文本:\1 和其他文本:\2/g'
请注意,我没有文本在文件(file2.txt)中
Okay, I figured out how to do this with sed.
sed 's/([^\t]) (.)/I want insert text here:\1 and the other text here: \2/g'
note that I didn't have the text in a file (file2.txt)