首页 > 解决方案 > 在 bash 中回显输出到文件的问题

问题描述

我遇到了一个问题,试图将一些字符串回显到 shell 脚本中的文件中。

我正在通过 pyspark/spark 的 rdd.pipe() 命令调用 shell 脚本,并通过回显 shell 脚本中的每一行来检查输入是否通过。

这是shell脚本代码:

#!/bin/sh
while read -r one; do
   read -r two
   read -r three
   read -r four
   read -r five
   read -r six
   read -r seven
   read -r eight
   echo -e "$one\n$two\n$three\n$four\n" >> 1.txt
   echo -e "$five\n$six\n$seven\n$eight\n" >> 2.txt
done

我在没有通过管道连接到文件的情况下运行了 echo 命令,并在我的 spark 程序的输出中显示了该命令。shell 脚本的输入只是字符串。有谁知道为什么 1.txt 和 2.txt 没有被写入?

标签: bashpyspark

解决方案


推荐阅读