是否可以使用管道将上一个命令的输出重定向到 sed,并让 sed 使用它作为输入(模式或字符串)来访问文件?
我知道如果你只使用 sed,你可以使用类似的东西
sed -i '1 i\anything' file
Run Code Online (Sandbox Code Playgroud)
但是我可以做类似的事情吗
head -1 file1 | sed -i '1 i\OutputFromPreviousCmd' file2
Run Code Online (Sandbox Code Playgroud)
这样,我不需要每次都手动复制输出并更改 sed 命令
更新:添加了我的意思的文件
head -3 file1.txt
Side A,Age(us),mm:ss.ms_us_ns_ps
84 Vendor Specific, 0000000009096, 0349588242
84 Vendor Specific, 0000000011691, 0349591828
Run Code Online (Sandbox Code Playgroud)
head -3 file2.txt
84 Vendor Specific, 0000000000418, 0349575322
83 Vendor Specific, 0000000002099, 0349575343
83 Vendor Specific, 0000000001628, 0349576662
Run Code Online (Sandbox Code Playgroud)
我想获取file1的第一行并将其插入到file2中,因此结果应该是:
head -3 file2.txt
Side A,Age(us),mm:ss.ms_us_ns_ps
84 Vendor Specific, 0000000000418, 0349575322
83 Vendor Specific, 0000000002099, 0349575343
83 Vendor Specific, 0000000001628, 0349576662
Run Code Online (Sandbox Code Playgroud) 我正在尝试自己编译跨平台工具链。
当我编译binutils-2.22时,它成功了,但为什么出现“检查我们是否正在交叉编译...否”?我想应该是“是”吧?
我的主机是运行ubuntu的i686,我的目标是arm。
~/telink_linux/build-tools/binutils-2.22$ ./configure --prefix=/home/shuaihan/telink_linux/tools --target=arm-linux
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... arm-unknown-linux-gnu
...
checking whether we are cross compiling... no
...
configure: creating ./config.status
config.status: creating Makefile
Run Code Online (Sandbox Code Playgroud)
之后,我“make”和“makeinstall”,创建了arm-linux-*。
谢谢!