Why does awk script not work on Mac OS but work on Linux?

I have an 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 

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

Update: MacOS X awk - version 20070501. However, the Ubuntu machine has mawk 1.3.3. The awk -version command does not work. I had to use awk -W -version. Therefore, I think, therefore, it works on Ubuntu, but does not work on MacOSX. So I downloaded mawk and installed it using fink, and now the command works on MacOSX. Thank you for your help.

Update2: Actually the problem was not awk. Usually I create csv files in R. Then I just run the script to filter. It turns out that if I open csv files in Excel or save the Excel file in csv format, then the script does not work (I tried to use different delimiters several times). Apparently, if you save the table in .csv format in MacOX (Excel 2011) and try to open it in Excel, it will say that it is a SYLK file. This description is on the Microsoft website. If I use OpenOffice, it works fine. Best.

+7
awk filtering macos
source share
2 answers

The same team name does not mean that it is the same team. Most basic commands have a different implementation, an example of AWK, but almost all GNU core utils have an equivalent in the BSD license. You have to be careful with GNU sed and BSD sed , this is also a trap.

In fact, Linux usually uses gawk or mawk :

 $ man awk mawk - pattern scanning and text processing language 

Mac OS usually uses nawk :

 $ man awk awk - pattern-directed scanning and processing language 

For more information on AWK implementations, see this page .

+8
source share

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

 ~$ 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) ~$ 
+4
source share

All Articles