使用 cat 命令时抑制错误消息

use*_*396 5 linux error-handling cat

我有一个脚本,我使用 cat 命令递归复制文件夹中文件的内容,如下所示

test -f /tmp/$F || cat $F > /tmp/$F
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

cat: read error: Invalid argument
Run Code Online (Sandbox Code Playgroud)

我想知道如何抑制此错误。我只能访问 shell 解释器(没有 bash)。

谢谢

Bar*_*ers 7

将错误消息发送至/dev/null.

cat $F 1>/tmp/$F 2>/dev/null
Run Code Online (Sandbox Code Playgroud)