Page 1 of 1
Command 'grep' and 'awk'
Posted: 16 Jul 2013 10:44
by pinto15
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
Re: Command 'grep' and 'awk'
Posted: 16 Jul 2013 12:15
by Samir
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.
Re: Command 'grep' and 'awk'
Posted: 16 Jul 2013 12:20
by Ocalabob
pinto15,
There are replies to your question on the other forum where you posted.
Re: Command 'grep' and 'awk'
Posted: 16 Jul 2013 13:38
by penpen
@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