awk

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 ...

Average of column by hours (rows) using awk

Hello, I have the following rows in a file that I want to get the average of the 3rd column by hour. 2010-10-28 12:02:36: 5.1721851 secs 2010-10-28 12:03:43: 4.4692638 secs 2010-10-28 12:04:51: 3.3770310 secs 2010-10-28 12:05:58: 4.6227063 secs 2010-10-28 12:07:08: 5.1650404 secs 2010-10-28 12:08:16: 3.2819025 secs 2010-10-28 13:01:...

Random numbers generation with awk in BASH shell

Dear all, I wish to shuffle the lines (the rows) of a file at random then print out to different five files. But I keep having exactly the same order of lines appeared in file1 to file5. The random generation process does not work properly. I would be grateful for any advices. #!/bin/bash for i in seq 1 5 do cat shuffling.txt | aw...

Extracting words in quotes in shell script

Hi! I am making a shell script that will automate the install process of Arch Linux AUR packages. I need to list all dependencies of the package (to check if they are installed), they appear like this in install script: depends=('sdl' 'libvorbis' 'openal') The easiest way (or the only idea) that I could come up with is something like...

AWK output to bash Array

Hi all, Im trying to put the contents of a simple command in to a bash array however im having a bit of trouble. df -h | awk '{ print $5" "$6 }' gives percentage used in the file systems on my system output looks like this: 1% /dev 1% /dev/shm 1% /var/run 0% /var/lock 22% /boot 22% /home 22% /home/steve I would then like to put ea...

How can I use awk to print a line only if its right half of line _doesn't_ match the previous line's right half?

I have text like: [100 ps] bar [139 ps] foo de fa fa [145 ps] foo de fa fa [147 ps] foo de fa fa [149 ps] le pamplemouse [150 ps] le pamplemouse [177 ps] le pomme de terre [178 ps] le pomme de terre In awk I want to filter out all the lines where the right half of the line matches the right half of the previous line. i.e. the...

Linux awk command

Hello, I am a beginner in using Linux, I have an input file with content like: 00.11.11.11.11.11 177.22.22.22 one line of Ethernet address and one line of IP address, how can I convert this file to: IP: 177.22.22.22 MAC: 00.11.11.11.11.11 I think awk would do it, but I don't know how. Any ideas? Thanks! ...

Column Filtering on Trace File

I am doing visualization analysis on a trace file I generate from ns-2 that traces out the packets sent/received/dropped at various times of the simulation here is a sample trace output - http://pastebin.com/aPm3EFax I want to filter out the column1 after grouping it into S/D/R separately, so that I can sum it over to separately to fin...

How to number the lines according to a field with awk?

Dear all, I wonder whether there is a way using awk to number the lines according to a field. For example, Input 2334 332 2334 546 2334 675 7890 222 7890 134 234 45 . . . Based on the 1st field, I would have the following output Output 1 2334 332 1 2334 546 1 2334 675 2 7890 222 2 7890 134 3 234 45 . . . I would be grateful ...

Problem with awk and grep

I am using the following script to get the running process to print the id, command.. if [ "`uname`" = "SunOS" ] then awk_c="nawk" ps_d="/usr/ucb/" time_parameter=7 else awk_c="awk" ps_d="" time_parameter=5 fi main_class=RiskEngine connection_string=db.regression AWK_CMD='BEGIN{printf "%-15s %-6s ...