为什么awk脚本不能在Mac OS上运行,而可以在Linux上运行? [英] Why awk script does not work on Mac OS but works on Linux?

查看:1078
本文介绍了为什么awk脚本不能在Mac OS上运行,而可以在Linux上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个awk脚本,可用来过滤差异表达的基因.我有一个在R中创建的csv文件.

I have this awk script that I use to filter genes that are differentially expressed. I have a csv file that was created in R.

 #Command to get DE genes
awk -F '\t' '$14 < 0.05 && $10 < -1 && $7 > 1 { print > "Genes-Down.csv" }
             $14 < 0.05 && $10 > +1 && $8 > 1 { print > "Genes-Up.csv" }' Results-RPKMs.csv

我现在开始在Mac OS上进行所有分析,并且相同的命令不起作用.它也不会给出任何错误信息.它运行并且什么也没有发生.其他sed命令也有同样的问题,但是使用awk制作新命令很容易.

I started doing all my analyses on Mac OS now and the same command does not work. It also does not give any error message. It runs and nothing happens. I also had same problems with other sed commands, but it was easy to make new ones using awk.

更新: MacOS X awk的版本为20070501.但是,Ubuntu计算机的版本为mawk 1.3.3.命令awk --version不起作用.不得不使用awk -W --version.因此,我认为这就是为什么它可以在Ubuntu上运行但不能在MacOSX上运行的原因.因此,我下载了mawk并使用fink进行了安装,现在该命令在MacOSX中可用.感谢您的帮助.

Update: The MacOS X awk is version 20070501. However, the Ubuntu machine has mawk 1.3.3. The command awk --version wouldn't work. Had to use awk -W --version. So I think that is why it works on Ubuntu but was not working in MacOSX. So I downloaded mawk and installed it using fink and now the command works in MacOSX. Thanks for your help.

Update2:实际上问题不是awk.通常,我在R中创建csv文件.然后我只运行脚本进行过滤.原来,如果我在Excel中打开csv文件或以csv格式保存Excel文件,则该脚本将不起作用(使用不同的定界符尝试了几次).显然,如果您在MacOX(Excel 2011)中将电子表格另存为.csv,然后尝试在Excel中重新打开它,则说明它是SYLK文件.在Microsoft网站上有对此的描述.如果我使用OpenOffice,它就可以正常工作.

Update2: Actually the problem was not awk. Usually I create the csv files in R. Then I just run the script to do the filtering. Turns out that if I open the csv files in Excel or save an Excel file in csv format then the script does not work (tried several times with different delimiters). Apparently if you save a spreadsheet as .csv in MacOX (Excel 2011) and try to open it back in Excel it says that it is a SYLK file. There is a description of this on Microsoft website. If I use OpenOffice, it works just fine.

推荐答案

我也遇到了同样的问题.通过 brew 在OSX 10.11.2上安装gawk解决了我的问题.

I also had the same problem. Installing gawk on OSX 10.11.2 through brew solved my issue.

~$ brew install gawk
~$ gawk --version | head -n 1
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.4-p1, GNU MP 6.1.1)
~$

这篇关于为什么awk脚本不能在Mac OS上运行,而可以在Linux上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆