我正在编写一个脚本,该脚本将分解usb驱动器,并使用加密的持久数据安装Kali linux。
#! /bin/bash
cd ~/Documents/Other/ISOs/Kali
echo "/dev/sdx x=?"
read x
echo "how many passes to wipe? 1 will be sufficient."
read n
echo "sd$x will be wiped $n times."
read -p "do you want to continue? [y/N] " -n 1 -r
ec
我希望将输出保存到文件中,同时,我也希望看到屏幕上的进度。
基本上,tee只为一行工作。有什么解决办法吗?
[user@linux ~]$ cat -n test.sh
1 echo line 1 | tee out.txt
2 echo line 2 | tee out.txt
3 echo line 3 | tee out.txt
4 ls -lh out*
[user@linux ~]$
[user@linux ~]$ ./test.sh
line 1
line 2
line 3
-rw-r--r-- 1 user user 7 M
我试图使用命令行将脚本的内容保存到文件中,但我注意到,当tee命令检测到诸如$(/usr/bin/id -u)之类的linux命令时,它执行命令,而不是按原样保存行。如何避免命令的执行和我输入的文本的保存?
$tee -a test.sh << EOF
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo You are not running as the root user.
exit 1;
fi;
EOF
if [[ 502 -ne 0 ]]; then
echo Yo