Rpmbuild copying folders specified by a mapping file

拥有回忆 提交于 2019-12-13 07:50:05

问题


Currently, working with rhel. Need to create a script that can use a mapping file (source and target need to be dynamic). What file type should be used for the mapping file (.csv, .txt, .json)?

  • End directory in a slash e.g. src/
  • -r can be used against a file e.g. cp -r src/file.fil tgt/
  • script will be kicked off by the spec file and files will be copied during build
  • source and target need to be dynamic

Script example

cp -r src/file.fil tgt/

Mapping file

<src>\t<tgt>\n e.g. src/file.fil \t tgt/ \n OR 'src/file.fil'\t'tgt/'\n


回答1:


xargs can be used for that

xargs --arg-file your-file.txt cp

file should contain lines like

file1 tgt/
file2 tgt/

or a for loop reading from a file with just source file names provided that your target is constant

for f in $(cat yourfile.txt); do
    cp "$f" tgt/
done

or even

while read src tgt; do
    cp "$src" "$tgt"
done < yourfile.txt


来源:https://stackoverflow.com/questions/48286904/rpmbuild-copying-folders-specified-by-a-mapping-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!