我有一个简单的shell脚本运行问题,其中我使用while循环读取文本文件并尝试使用匹配正则表达式检查条件:
#!/bin/sh
regex="^sometext"
cat input.txt |
{
while read string
do if [[ $string ~= $regex ]]; then
echo "$string" | awk '{print $1}' >> output.txt
else
echo "$string" >> outfile.txt
fi
done
}
但我只收到类似错误的信息。
[[: not found
请问能否提供一些具体的信息?
echo "$string" | awk '{print $1}' | base64 -d | iconv -f UTF-8 -t KOI8-R >> outfile.txt
。 - P.S.{print $1 | "myscript.sh"; close("myscript.sh"); next}
(close 确保脚本输出在任何下一行之前)。 - Amber