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.
我有一个fold.txt包含一行的文本文件fold_nam:
fold.txt
fold_nam
$ cat fold.txt fold_nam
文本文件中的此名称是在文件夹名称的程序运行期间创建的输出,该文件夹名称现在包含我需要使用的其他文件。
我正在写一个大脚本,现在我需要进入这个文件夹,我需要从文本文件中获取名称。我尝试了几件事,但无法真正解决。
如果要将行读入变量:read -r folder_name < fold.txt
read -r folder_name < fold.txt
没有必要使用cat:
cat
cd $(<fold.txt)
你应该能够做到这一点:
cd $(cat fold.txt)
或者
cd `cat fold.txt`