我想知道如何检查Nushell中是否存在目录?
发布于 2022-11-22 16:14:39
使用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。
https://stackoverflow.com/questions/74533599
复制相似问题