Solved

awk in windows

Posted on 2006-11-28
6
1,613 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
haveThree challenge 22 123
Modbus - whats the maximum I can store in one register? 4 82
Path of Workbook 3 87
c++  placing data into a form and an editbox 5 24
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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