我读到写这样的东西很不好,for line in $(command)相反,正确的方法似乎是: command | while IFS= read -r line; do echo $line; done 这很好。但是,如果要迭代的是变量的内容而不是命令的直接结果,该怎么办? 例如,假设您创建以下文件quickfox: The quick brown foxjumps\ over - the lazy , dog. 我希望能够做这样的事情: # This is just for the example, # I could of course stream the contents to `read` variable=$(cat quickfox); while IFS= read …
哪些权限会影响硬链接的创建?文件所有权本身重要吗? 假设用户alice想target.txt在目录中创建到文件的硬链接target-dir。 和都alice需要哪些权限?target.txttarget-dir 如果target.txt是由用户拥有bill和target-dir被用户所拥有chad,它改变什么? 我试图模拟这种情况,在ext4文件系统中创建以下文件夹/文件结构: #> ls -lh . * .: drwxr-xr-x 2 bill bill 60 Oct 1 11:29 source-dir drwxrwxrwx 2 chad chad 60 Oct 1 11:40 target-dir source-dir: -r--r--r-- 1 bill bill 0 Oct 1 11:29 target.txt target-dir: -rw-rw-r-- 1 alice alice 0 Oct 1 11:40 dummy 虽然alice可以创建到的软链接target.txt,但她不能创建硬链接: …