Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以这是我使用代码时的问题:
for i in filename.txt do <operations> done
正在对文件内容和文件名本身进行操作,为什么会发生这种情况?
为了清楚起见,我已经有 2 个解决方案可以解决这个问题,但我仍然不明白为什么会这样。对我有用的解决方案之一:
for i in $(cat filename.txt) do tar -czf ${i}.tar $i rm -R $i gzip $i.tar done
“是的。在 for i in filename.txt 中,您将有一个 $i 并将其设置为 filename.txt。如果您想读取 $i 的内容 - 在循环中执行此操作。” 谢谢特德·林格莫。