linux - 执行linux命令将文本文件中的pdf文件复制到目录

标签 linux shell cp

我的文本文件中有一个名为“pdf.txt”的 pdf 文件列表。如何使用 Linux 命令将其复制到目录/home/temporary。

#!/bin/bash
pdf=cat pdf.txt
cp -R $pdf /home/temporary/b

这不起作用。

最佳答案

假设每行一个文件,这应该可以做到:

#!/bin/bash
IFS=$'\n' # split on newlines, not whitespace in case filenames have spaces
for line in $(cat pdf.txt); do
    cp "${line}" /home/temporary/b
done

关于linux - 执行linux命令将文本文件中的pdf文件复制到目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56333083/

相关文章:

linux - 使用 Awk 处理每条记录具有不同固定宽度字段的文件

linux - Python 3 - 无法接收 IPv6 数据包(UDP - linux)

linux - 我如何重命名具有不同扩展名的文件夹中的前 5 个文件,同时保持旧文件相同?

git - 有没有git命令美化两个分支之间git diff的输出?

bash - 我可以使用 xargs 作为目录路径的一部分吗?

macos - 在Mac中复制文件同时保留目录结构

c - 如何显示 'preprocessed' 代码忽略包括 GCC

linux - 管道 ls 到 head 会停止它的执行吗?

linux - 根据扩展名识别文件

linux - bash 脚本如何确保运行的副本不超过一个?