bash - 在 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 没有被写入?
解决方案
推荐阅读
- java - 即使 jar 工作正常,Launch4j 也无法找到主类
- file - 如何将存储在 wwwroot 中的 csv 文件读入 Blazor Webassembly 上的 StreamReader?
- python - 将 for 循环转换为 while 循环 Python
- android - Android Studio:新添加的模块未显示在项目结构窗口中
- c# - 在 ASP.Net C# 中的 CKEditor 中粘贴图像
- c++ - 为什么 decltype 不实例化这个递归函数原型?
- sas - 在 WRDS 批处理作业上连接 API 的问题
- c - 链表中显示节点的代码不起作用
- ios - SwiftUI @Published 属性不更新视图
- python - 类级别的访问器和修改器方法的 Pythonic 方式