Gawk help (windows)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Gawk help (windows)
# 15  
Old 02-22-2011
Thanks for the reply ctsng, but I still get a blank output. What's going on?Smilie
# 16  
Old 02-22-2011
Quote:
Originally Posted by harris_t
No. That gives me some warning escape sequence error.
Try putting the code that I supplied earlier into a file, not the subsequent variations that use escapes.
Code:
$1=="NTP"{gsub(/[^0-9\.]*/,"",$2);print $2}

Otherwise install Cygwin, which gives you a bash shell under Windows and some utilities like gawk.
# 17  
Old 02-22-2011
You could also try this simplified awk script without " in the program (BTW probably best to keep the sign on the front as adjustments can be negative too):

Code:
C:\home\cubler> gawk -F "[s ]" "/^NTP:/ { print $2 }" time
+0.0162516

Without +/- sign:
Code:
C:\home\cubler> gawk -F "[s+-]" "/^NTP:/ { print $2 }" time
0.0162516


Last edited by Chubler_XL; 02-22-2011 at 11:09 PM..
# 18  
Old 02-22-2011
I prefer to use grep

grep -o "[+-]\?[0-9]\+\.[0-9]\+s" ufile
This User Gave Thanks to justlooks For This Post:
# 19  
Old 02-23-2011
Everyone's gawk solutions look great but they keep giving me blank outputs..

Quote:
Originally Posted by justlooks
I prefer to use grep

grep -o "[+-]\?[0-9]\+\.[0-9]\+s" ufile
This the best one I've got so far, my output is:
Code:
+0.0162516s

Is there a way we can exclude the + and s?


---------- Post updated at 03:24 AM ---------- Previous update was at 03:18 AM ----------

Yes. It has been done. Thank you guys. Especially justlooks. Thank you
!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!

Code:
grep -o "[0-9]\+\.[0-9]\+s" time | tr -d 's'


Last edited by Franklin52; 02-23-2011 at 05:01 AM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Gawk on Windows: Joining lines only if 1st field matches

Hi.. i have two files:: file_1:: mOnkey huMAnfile_2:: Human:hates:banana i:like:*** Monkey:loves:banana dogs:kill:catsdesired output:: Monkey:loves:banana Human:hates:bananaso only when the 1st field matches from both files print it from file_2 ((case-sensitive)) i also would like... (21 Replies)
Discussion started by: M@LIK
21 Replies

2. Windows & DOS: Issues & Discussions

Gawk Script in Windows batch file - Help

Good morning all. I have been running into a problem running a simple gawk script that selects every third line from an input file and writes it to an output file. gawk "NR%3==0" FileIn > FileOut I am attempting to run this command from a batch file at the command line. I have several hundred... (6 Replies)
Discussion started by: 10000springs
6 Replies

3. Shell Programming and Scripting

Gawk Help

Hi, I am using the script to print the portion of the file containing a particular string. But it is giving error "For Reading (No such file or directory). I am using cygwin as unix simulator. cat TT35*.log | gawk -v search="12345678" ' /mSOriginating /,/disconnectingParty/ { ... (1 Reply)
Discussion started by: vanand420
1 Replies

4. Shell Programming and Scripting

How can I make running gawk scripts more user-friendly in a Windows environment?

I know, and I apologise for using the W word, but I have users asking if they can use my gawk scripts, but I just know they're not going to like using the DOS command line. Is there any way for me to run my gawk scripts from a gui? Even if it's from a web page (html, php, what ever). I do not... (3 Replies)
Discussion started by: jonathanm
3 Replies

5. Shell Programming and Scripting

gawk HELP

I have to compare records in two files. It can be done using gawk/awk but i am unable to do it. Please help me File1 ABAAAAAB BC asa sa ABAAABAA BC bsa sm ABBBBAAA BC bxz sa ABAAABAB BC csa sa ABAAAAAA BC dsa sm ABBBBAAB BC dxz sa File 2 ABAAAAAB BC aas ba ABAAAAAB BC asa sa... (6 Replies)
Discussion started by: sandeep_hi
6 Replies
Login or Register to Ask a Question