2

I am trying to write a script that would combine two files into one and should work in both Solaris 5.10 and a Linux box.

File1:

dit710
dit710
dit720
dit720

File2:

FacA D0000000000000001
FacA D0000000000000002
FacA D0000000000000030
FacB D00000000000000980

Desired Output:

dit710,FacA,D0000000000000001
dit710,FacA,D0000000000000002
dit720,FacA,D0000000000000030
dit720,FacB,D00000000000000980

What I tried?

paste File1 File2 |nawk '{$1=$1}1' OFS=","

(Above command works in Solaris but does not work in Linux)

paste File1 File2 |awk '{$1=$1}1' OFS=","

(Above command works in Linux but does not work in Solaris)

I am using Korn Shell. Can someone suggest another way which works in both Solaris and Linux?

Note that File2 may contain more than 3 columns but always have equal number of columns.

ayrton_senna
  • 1,091

1 Answers1

2

I was able to resolve this issue myself, but I wouldn't call it a straight forward approach. Since awk works in Linux, but not nawk, I created a soft link in Linux host to redirect nawk to awk. Now I can use nawk in both Solaris and Linux without any issues.

ln -s /bin/awk /bin/nawk
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
ayrton_senna
  • 1,091
  • Not sure what distro you are running but Debian based distributions at least, automatically create this link. – psusi Apr 06 '16 at 01:22