bash - 通过 xargs 连接带有变量的字符串

标签 bash

假设我要touch 六个文件

one.html
one.css
two.html
two.css
three.html
three.css

我如何为此使用xargs?我正在查看手册页,但不确定获取标准输入管道的语法。

$ echo one two three | xargs -n 1 touch $1.html $1.css // nope

最佳答案

如果使用xargs 很重要:

printf "%s\n" one two three | xargs  -I{} touch {}.html {}.css

关于bash - 通过 xargs 连接带有变量的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39026100/

相关文章:

c - 迭代机器代码时遇到问题

bash - 使用 awk 重新格式化文本文件并将其剪切为单行

bash - "echo ' hello';之间的区别ls"vs "echo ' 你好' && ls"?

arrays - Bash 数组分组元素

regex - Bash 正则表达式匹配 "0xffffffc0006e0584 is in some_function (/path/to/my/file.c:93)."

bash - crontab 上的备份脚本不起作用

git - 从 PS1 提示符运行 git update-index --refresh 安全吗?

bash - 使用ssh将变量发送到远程服务器

linux - 连接丢失时自动关闭 PuTTY

java - 将线程进程 ID 转换为十六进制格式