Macos 将windows批处理文件转换为使用mac sh文件
我有这个批处理文件,它在Windows中运行良好,但我也想在我的mac上使用它 Windows批处理文件:Macos 将windows批处理文件转换为使用mac sh文件,macos,batch-file,sh,Macos,Batch File,Sh,我有这个批处理文件,它在Windows中运行良好,但我也想在我的mac上使用它 Windows批处理文件: for /r %1 %%f in (info.txt) do echo. >>output.txt & awk "{$1=\"\"; print $0}" "%%f" |awk -F"\n" "{if(NR == 1) {printf $0} else {printf \"*\"$0}}" >>output.txt 批处理文件正在读取主目录和所有子目录中的
for /r %1 %%f in (info.txt) do echo. >>output.txt & awk "{$1=\"\"; print $0}" "%%f" |awk -F"\n" "{if(NR == 1) {printf $0} else {printf \"*\"$0}}" >>output.txt
批处理文件正在读取主目录和所有子目录中的info.txt,并将该信息放入demain目录中的output.txt
例如,我在主目录中有一个info.txt文件,在子目录中有第二个info.txt文件
info.txt看起来像这样:
Title: This is Great
Composer: Me
Title: The Best
Composer: You
SUB中的其他info.txt如下所示:
Title: This is Great
Composer: Me
Title: The Best
Composer: You
output.txt如下所示:
This is Great*Me
The Best*You
有人能帮我转换批处理文件,这样我就可以直接在macshell中执行它了吗?
我现在遇到的问题是,如何在sh的for循环中使用%1和%%f,以便传递变量?很抱歉,此网站不是免费的代码编写服务。请编写您自己的代码,如果在运行过程中出现特定的可复制问题,请将该代码以及足够的支持信息包括在内,以便我们为您提供帮助。Windows 10可以安装Linux子系统。所以基本上你得到了一个bashshell。如果您想要可移植性,我建议您为BASH编写它,以便它可以在两个系统上运行。