I want to read a file and save it in variable, but I need to keep the variable and not just print out the file.
(我想读取文件并将其保存在变量中,但我需要保留变量,而不仅仅是打印文件。)
How can I do this? (我怎样才能做到这一点?)
I have written this script but it isn't quite what I needed: (我已经编写了此脚本,但它并不是我所需要的:)
#!/bin/sh
while read LINE
do
echo $LINE
done <$1
echo 11111-----------
echo $LINE
In my script, I can give the file name as a parameter, so, if the file contains "aaaa", for example, it would print out this:
(在我的脚本中,我可以将文件名作为参数,因此,例如,如果文件包含“ aaaa”,它将输出以下内容:)
aaaa
11111-----
But this just prints out the file onto the screen, and I want to save it into a variable!
(但这只是将文件打印到屏幕上,我想将其保存到变量中!)
Is there an easy way to do this? (是否有捷径可寻?)
ask by kaka translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…