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.
我需要使用 c shell 打开一个文件。该文件包含一个整数,我需要将它放入一个变量中,增加它并放回文件中。意思是,如果文件包含数字 5,我需要在程序运行后,该文件包含数字 6。有什么建议吗?
您可以使用该@命令将其计算为数值表达式。
@
% echo 100 > test.txt % set f = `cat test.txt` % echo $f 100 % @ f = $f + 1 % echo $f 101 % echo $f > test.txt % cat test.txt 101
Or this:
expr `cat /tmp/X` + 1
(those are backquotes).