linux系统Shell脚本,如何文本保存

#===============#!/bin/sh
fname=”$1″
exec<$fname
regex=’^([a-z]{1,1})([a|e|i|o|u]{1,1})([a-z]{1,4})\.com(.+)’
while read line
do
if [[ "$line" =~ $regex ]];then
echo $line
fidone
#================这个shell脚本,是判断之后打印出来,但是我在vps linux系统中使用命令怎么 把结果以文本形式保存下来,希望具体给出答案 本人小白

倒数第三行 echo $line后面添加输出重定向
vim shell脚本 修改
echo $line >>output.txt 2>&1
wq保存
其中记录信息的output.txt位于脚本当前目录下面 2>&1 是错误信息也会记录到output.txt里面
温馨提示:答案为网友推荐,仅供参考
相似回答