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.
我有一个 txt 文件,里面只有一个数字;它可以是任何数字,我如何从 bash 中读取它并将其转换为 int?
正如我所说,文件中唯一的内容是数字,没有其他内容,但是在读取它时,bash 将其作为字符串获取。
提前致谢!
使用declare或typeset:
declare
typeset
typeset -i variable=$(cat filename)