Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-16-2008
amatuer_lee_3 amatuer_lee_3 is offline
Registered User
 

Join Date: May 2008
Posts: 53
Awk output issues.

I have the follwing code:


Code:
awk '{print $1}' HITS                                   #Searches HITS file column one. Column one is filenames

awk '{print $2}' HITS  | sort -n | wc -l            #Searches HITS file and sorts numerically and outputs line count. column 2 is IP addresses

awk '{print $2}' HITS | uniq | wc -l                # Searches HITS file for unique entries and outputs line count. column 2 is IP addresses

i know my code is not right and my results are not listed how i want it. they are just displayed one after the other on seperate lines.

like this:

Code:
hits/adverts.hits:248.204.125.183
hits/mags.hits:87.114.172.31
hits/adverts.hits:34.220.19.30
hits/food.hits:185.227.145.86
hits/food.hits:213.225.8.140
hits/mags.hits:83.222.98.178
hits/food.hits:118.195.119.35
10345
245

What I want them to all be on the same line in a table to look like this:


Code:
FILENAME                    HITS                       UNIQUE HITS
food.hits                   2034                            245
mags.hits                   2000                            435
adverts.hits                1456                            344

#the hits column needs to also be in a descending order as shown above


Last edited by amatuer_lee_3; 05-16-2008 at 05:04 AM..
Sponsored Links