如何将两个 sed 命令的迭代结果打印在输出文件的同一行上?
How can I have the iterative results from two sed commands printed on the same line of an output file?
我有 4,000 多个文本文件,其中包含来自配件的数据 - 应用简单模型得出的不同物理值。这些文件具有命名约定:file_##,##_hill5.txt(其中##,## 是每个文件的坐标表示)。我需要一个特定的数据值以及要打印到同一个输出文件的文件名的一部分。环顾 sed 问题的可用答案并根据我的需要进行编辑,我想出了:
ls *.txt | sed -n '/^# Tau: */s///p;y/ /\n/' > results.txt
--这条命令导出tau的值,即??????来自“陶:??????”来自每个文本文件。
我的第二个 sed 命令:
sed -n s/.*_\([0-9]*,[0-9]*\)_.*//p * > results.txt
从文件名导出##,## 坐标值。
运行 文件集上每个 sed 代码的输出是:
3.09428
3.35559
3.75969
4.42674
5.57755
和
24,15
23,14
21,17
17,18
19,10
但是,我希望并排打印 tau 值和数字集;即,
3.09428 24,15
3.35559 23,14
3.75969 21,17
4.42674 17,18
5.57755 19,10
是否可以使用单个 sed 命令?
How can I have the iterative results from two sed commands printed on the same line of an output file?
使用paste
或其他工具。
Is this possible with sed?
不仅在sed
,不。需要外部工具或额外的预制参数。
我有 4,000 多个文本文件,其中包含来自配件的数据 - 应用简单模型得出的不同物理值。这些文件具有命名约定:file_##,##_hill5.txt(其中##,## 是每个文件的坐标表示)。我需要一个特定的数据值以及要打印到同一个输出文件的文件名的一部分。环顾 sed 问题的可用答案并根据我的需要进行编辑,我想出了:
ls *.txt | sed -n '/^# Tau: */s///p;y/ /\n/' > results.txt
--这条命令导出tau的值,即??????来自“陶:??????”来自每个文本文件。
我的第二个 sed 命令:
sed -n s/.*_\([0-9]*,[0-9]*\)_.*//p * > results.txt
从文件名导出##,## 坐标值。
运行 文件集上每个 sed 代码的输出是:
3.09428
3.35559
3.75969
4.42674
5.57755
和
24,15
23,14
21,17
17,18
19,10
但是,我希望并排打印 tau 值和数字集;即,
3.09428 24,15
3.35559 23,14
3.75969 21,17
4.42674 17,18
5.57755 19,10
是否可以使用单个 sed 命令?
How can I have the iterative results from two sed commands printed on the same line of an output file?
使用paste
或其他工具。
Is this possible with sed?
不仅在sed
,不。需要外部工具或额外的预制参数。