将中间文件保存为 bash 脚本中的变量

Save intermediate files as variables in bash script

这是我第一次开始编写可执行的 bash 脚本。 我有四个命令行,我想将它们放入一个 .sh 文件中,然后放入单个 csv 文件中的 运行。 我想避免使用一长串命令,例如command1 | command2 | command3 | command4 相反,我需要将中间输出保存在临时变量中或使用某些东西代替管道。

我试过了,但没有给出正确的输出:

filename=""
outputname=""

if  [[  = "-u" ]]; then
    out= cut -f1,3,7,8  "${filename}" | grep "*_11_0" | tr , ':'
    out2= awk '{print ,}' "${out}"
    echo "${out}"

else
    echo "Error: You have to specify an option"
fi

Could you please make an example command of saving intermediate variables with my written script above

out=$(cut -f1,3,7,8  "$filename" | grep "*_11_0" | tr , ':')
out2=$(printf "%s\n" "$out" | awk '{print ,}')
# or out2=$(awk '{print ,}' <<<"$out") in bash