Solved

awk in windows

Posted on 2006-11-28
6
1,555 Views
Last Modified: 2013-12-26
This works fine in linux /unix
cat file.txt    |   awk -F ";" '{  printf(",%s,%s,%s,%s,\n", substr($21,0,10),$99,$105,$104)}' > lrep_1.txt
i am trying to run this in windows like this
cat file.txt    |  g awk -F ";" '{  printf(",%s,%s,%s,%s,\n", substr($21,0,10),$99,$105,$104)}' > lrep_1.txt

Attached is the error

C:\iscripts>cat file.txt    |   gawk -F ";" '{  printf(",%s,
%s,%s,%s,\n", substr($21,0,10),$99,$105,$104)}' > lrep_1.txt
gawk: cmd. line:1: '{
gawk: cmd. line:1: ^ Invalid char ''' in expression

Thanks for the help in advance
0
Comment
Question by:prgeorge3383
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18031973
in windows you usually need to quote a command argument with "" instead of ''
0
 

Author Comment

by:prgeorge3383
ID: 18039256
tried this .... does not work
cat file.txt    |  gawk -F "";"" ""{  printf(",%s,%s,%s,%s,\n", substr($21,0,10),$99,$105,$104)}""

cat file.txt    |  gawk -F ";" ""{  printf(",%s,%s,%s,%s,\n", substr($21,0,10),$99,$105,$104)}""

thanks
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 18040449
ozo meant that you use
  cat file.txt    |  gawk -F ";" "{  printf(',%s,%s,%s,%s,\n', substr($21,0,10),$99,$105,$104)}"

but I guess that you then struggle with ' inside the awk script
in such unreliable systems (Windoze, cmd.exe, whatever) you better use a file for you awk commands
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 84

Expert Comment

by:ozo
ID: 18040543
try
cat file.txt    |   gawk -F ";" "{  printf("",%s,%s,%s,%s,\n"", substr($21,0,10),$99,$105,$104)}"
0
 

Author Comment

by:prgeorge3383
ID: 18040716
will try the file... that is probably the best way
0
 
LVL 21

Accepted Solution

by:
oleggold earned 500 total points
ID: 18066111
I would recommend to use POSIX utilities for windows from:
http://www.gams.com/contrib/gbin/gbin.htm
or the full and FREE version of cygwin POSIX TOOLS at:
http://www.cygwin.com/setup.exe
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now