一次将文件复制到多个目录

时间:2020-08-10 09:47:30

标签: linux shell unix cp

{
 "manifest_version": 2,
 "short_name": "React App",
 "name": "Create React App Sample",
 "description": "google chrome  extension",
 "version": "1.0",
 "browser_action": {
 "default_icon": "favicon.ico",
 "default_popup": "index.html"
 },
"background": {
    "scripts": ["background.js"]
  },
 "permissions": [
  "tabs"
],
 "start_url": ".",
 "display": "standalone",
 "theme_color": "#000000",
 "background_color": "#ffffff"
}

我想将mkdir dir{0..99} echo hello > file 复制到每个目录,file复制到dir0

目前,我想到的最好的解决方案是:

dir99

但是必须有更优雅的方法来做到这一点。

是否可以使用类似于下面的命令将文件for i in {0..99}; do cp file dir$i; done 到多个目录?

cp

1 个答案:

答案 0 :(得分:0)

您可以使用xargs呼叫cp 100次:

echo dir{0..99} | xargs -n 1 cp file

检查xargs的人