Solved

awk in windows

Posted on 2006-11-28
6
1,544 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

19 Experts available now in Live!

Get 1:1 Help Now