Linux 中带格式化字符串参数的 stat 命令

stat command with formatted string argument in Linux

我想将某些文件的字符串变量(例如:'file1\nfile2\nfile3')作为参数传递给 Linux 中的 stat 命令。实际上,我知道 stat file1 file2 file3,但我想用 \n 传递 format 字符串。谢谢。

您可能想从 xargs 执行 stat,因为 stat 命令只接受一个或多个文件(但不接受任何格式化字符串)

例如,您可以执行以下操作:

echo -e "file1\nfile2\nfile3\nmydir" | xargs stat