Command 'grep' and 'awk'

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pinto15
Posts: 1
Joined: 16 Jul 2013 10:38

Command 'grep' and 'awk'

#1 Post by pinto15 » 16 Jul 2013 10:44

Hi guys,

I'm learning how to use MS-Dos and I have a code to implement:
gpdcreport my_run.report -gm -m 1 | gprofile -vs -resample -d 50 -n 50 | grep -v "#" | awk '{print $2,$1}' | gphistogram -y-min 150 -y-max 3500 -x-min 1 -x-max 50 -x-count 50


This works just fine, till the command grep and awk
Anyone knows how to solve this?

Probably it's a dumb question. I'm a newbie in Ms-dos.
Thanks

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Command 'grep' and 'awk'

#2 Post by Samir » 16 Jul 2013 12:15

grep and awk are both unix commands so they don't work in dos. Now, I know there are "unix-for-dos" libraries out there that will add these features to dos. Then you can just use your script as is. 8)

Ocalabob
Posts: 79
Joined: 24 Dec 2010 12:16
Location: Micanopy Florida

Re: Command 'grep' and 'awk'

#3 Post by Ocalabob » 16 Jul 2013 12:20

pinto15,
There are replies to your question on the other forum where you posted.

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Command 'grep' and 'awk'

#4 Post by penpen » 16 Jul 2013 13:38

@Ocalabob
I've only found one other forum in where pinto15 has posted the same question, and the answer is nearly Samir's first sentence.
The other forum with the command line is a forum in that this command line is a result, so it should work as is: http://www.geopsy.org/forum/viewtopic.php?t=115

@pinto15
I assume mingw is installed on your system with some tools from geopsy and others. You should run these commands from the mingw shell and not from cmd shell. I assume another gprofile program is installed, and you are using the false one. Running from mingw shell should prevent such situations, if mingw and the programs for it are installed properly.

If it is not as i assumed, you may store all intermediate result using the redirection operator (>) at any point:

Code: Select all

gpdcreport my_run.report -gm -m 1 > gpdcreportResult.txt
gpdcreport my_run.report -gm -m 1 | gprofile -vs -resample -d 50 -n 50 > gpdcreportResult.txt
gpdcreport my_run.report -gm -m 1 | gprofile -vs -resample -d 50 -n 50 | grep -v "#" > grepResult.txt
gpdcreport my_run.report -gm -m 1 | gprofile -vs -resample -d 50 -n 50 | grep -v "#" | awk '{print $2,$1}' > awkResult.txt
I think you should know how the intermediate results should look like.

penpen

Post Reply