I am trying to split a file using AWK on a specific separator. The awk code looks like this:

awk '/SEPARATOR/{n++}{print &gt; "part" n ".txt" }' in.txt


this code works perfectly on my Linux systems. But when running exactly the same code on Mac OS X i get the following error:

awk: syntax error at source line 1
 context is
    /SEPARATOR/{n++}{print &gt; "part" &gt;&gt;&gt;  n &lt;&lt;&lt;  ".txt" }
awk: illegal statement at source line 1


I assume that this is some kind of difference between the awk that ships with OS X and mawk from Linux. Removing the string concatenation in the print gets the awk program to work on both platforms, but I would prefer to keep the prefix and surfix. How do I write an awk program that splits a file on a separator into multiple numbered parts and works on both platforms?


Question: Can only access one of the router's web portal and the Internet
Answer: The fact that your are getting assigned IPs on two different subnets implies you have two DHCP servers on the directly attached network.

Usually, I'd recommend using something like dhcp_probe -f eth0 or roguechecker to find out which IPs on your network are serving DHCP but you already know which they are. Namely, 192.168.1.1 and 192.168.102.1. 

You have two options to get internet connectivity AND be able to connect to the 192.168.1.0 network at the same time. Both will require disabling or removing the DHCP server on 192.168.1.1 and letting 192.168.102.1 assign you an IP for internet access.

Methods follow:

1) Add a static routing entry to the linux box that tells it that 192.168.1.0 is directly attached.

route add -net 192.168.1.0/24 wlan0 should work for this.

2) Add a static routing entry to the router that tells it 192.168.1.0 is directly attached.

This would be specific to your router/firmware, but since you're running DD-WRT you can easily find the information on adding a static route. As a note, your gateway should be 0.0.0.0 for directly connected nets.