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.
我正在使用 bash 脚本,我必须将文件的最后 n-2 行存储在变量中。我用于此的命令是
last_n2_lines=`tail -n+3 $file`
现在,每当我回显 $last_n2_lines 变量时,我都会将文件的所有行放在一行中。如何获得与原始文件相同的格式。我试过 printf 但它只打印第一个字段。
试试这个:
echo "$last_n2_lines"
echo在您的变体中看不到原始值,因为它已分解为argv数组。
echo
argv