我想知道如何在Nushell中检查目录是否存在?
path exists
。 示例:> "/home" | path exists
true
> "MRE" | path exists
false
> "./nu-0.71.0-x86_64-unknown-linux-gnu" | path exists
true
> [ '.', '/home', 'MRE'] | path exists
╭───┬───────╮
│ 0 │ true │
│ 1 │ true │
│ 2 │ false │
╰───┴───────╯
> if ([ '.', '/home', '/proc'] | path exists | reduce -f true { |it, acc| $acc and $it }) {
"All directories exists"
} else {
"One ore more directories are missing"
}
All directories exists
请查看help path exists
以获取更多详细信息,并查看help path
以获取更多路径帮助内置函数。