5

bash中如何遍历带空格的文件名

 3 years ago
source link: https://www.lujun9972.win/blog/2018/09/27/bash%E4%B8%AD%E5%A6%82%E4%BD%95%E9%81%8D%E5%8E%86%E5%B8%A6%E7%A9%BA%E6%A0%BC%E7%9A%84%E6%96%87%E4%BB%B6%E5%90%8D/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
bash中如何遍历带空格的文件名 - 暗无天日

bash中如何遍历带空格的文件名

若要遍历的文件名带空格,则不能直接用 $(ls) 来做进程替换,而应该用通配符由shell进行扩展。

即应该是:

for f in *.md
do
    echo $f
done
for f in $(ls *.md)
do
    echo $f
done
2018-09-27 2018-09-27 编程之旅 bash shell lujun9972

Related Issues not found

Please contact @lujun9972 to initialize the comment

Generated by Emacs 27.x(Org mode 9.x)

Copyright © 2014 - 2021 lujun9972   -   Powered by EGO
Themed with emacs_love


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK