nawk

Script with nawk doesn't print output to screen

I came across a nice one-liner to search for text and print out the results with a given number of trailing and following lines. I'm trying to create a script out of this. So far this is what I have: # ********************************************************* # This uses nawk to list lines coming prior to and after # the given search st...

awk use comma(optional) followed by multiple blanks as FS

What I need to do is parse a string of the following form -option optionArgument, --alternativeNotation Some text, nothing of interest... I set the FS to BEGIN { FS = ",?\ +" } but it didn't work... it should break on every random number of blanks (at least one), preceeded by a comma (optional). Any ideas? Thx in advance, ...

Solaris awk Troubles

I'm writing a shell script and I need to strip FIND ME out of something like this: * *[**FIND ME**](find me)*
 and assign it to an array. I had the code working flawlessly .. until I moved the script in Solaris to a non-global zone. Here is the code I used before: objectArray[$i]=`echo $line | nawk -F '*[**|**]' '{print $2}'` ...

how can i print the column in text file to row wise using unix command?

I have file like this.. for eg: number,dac,amountdac,expdate,0 1111,1,0.000000,2010-07-21,0 1111,2,0.000000,2010-07-21,0 1111,3,0.000000,2010-07-21,0 1111,4,0.000000,2010-07-21,0 1111,5,0.000000,2010-07-21,0 1111,6,0.000000,2010-07-21,0 1111,7,0.000000,2010-07-21,0 1111,8,0.000000,2010-07-21,0 1111,9,0.000000,2010-07-21,0 1111,10,0.0000...

alternative to tail -F

Hi, I am monitoring a log file by doing "TAIL -n -0 -F filename". But this is taking up a lof of CPU as there are many messages being written to the logfile. Is there a way, I can open a file and read new/few entries and close it and repeat it every 5 second interval? So that I don't need to keep following the file? How can I remember t...

Using strftime function in mawk

I'm trying to create AWK script that will filter the input file according to some pattern, and use the strftime() function for some calculations. ($2 ~ /^[HB]/ && $2 ~ /n$/){ print strftime("%Y") } The interpreter in use is mawk. When triggering this script using this command: awk -f script3 inputFile I'm getting the error...

exit out of an awk function

How do I exit out of an awk function? "exit" stops entire program? ...

Problem with replace command

I have some problem with replace command. Input file i have this {a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]} I want to replace with single quotes '{a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]}' Using the below mentioned command find input.txt -exec sed 's/{a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]}/'{a[$1]=a[$1]FS$2}END{f...

UNIX:How to convert ip address to binary code

Is there is any Command to convert ip address in to binary form? Eg: 10.110.11.116 output: 00001010.01101110.00001011.01110100 ...