[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

awk in windows

Posted on 2006-11-28
6
Medium Priority
?
1,741 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

649 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