Sponsored Content
Full Discussion: Awk output issues.
Top Forums Shell Programming and Scripting Awk output issues. Post 302195757 by amatuer_lee_3 on Thursday 15th of May 2008 11:06:46 PM
Old 05-16-2008
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..
 

10 More Discussions You Might Find Interesting

1. AIX

Issues with AWK

Hi there I have written a ksh script on a Red Hat OS and the following extract works. awk '{if (NR != 1) {print $rec1_field }}' $file1 >> combined When I run the same script on an AIX OS, I get the following error. awk: 0602-562 Field $() is not correct. The input line number is 2. The... (12 Replies)
Discussion started by: alanp
12 Replies

2. UNIX for Dummies Questions & Answers

Awk Performance Issues

Hi All, I'm facing an issue in my awk script. The script is processing a large text file having the details of a number of persons, each person's details being written from 100 to 250 tags as given below: 100 START| 101klklk| ... 245 opr| 246 55| 250 END| 100 START| ... 245 pp| 246... (4 Replies)
Discussion started by: pgp_acc1
4 Replies

3. Shell Programming and Scripting

Awk OFS issues

Hi Im trying to tidy up the output of a who command when it writes to a log, everything I've tried doesnt seem to work though, any help would be massively appreciated. Im using the awk command to set the OFS as tab. #!/bin/bash who >> /export/home/tjmoore/logusers awk -F 'BEGIN... (3 Replies)
Discussion started by: 02JayJay02
3 Replies

4. Shell Programming and Scripting

Awk OFS issues

Hi, Could anyone tell me what Im doing wrong here any help will be much appreciated #!/bin/bash ls -ltr /export/home/tjmoore > /export/home/tjmoore/log100 awk -F " " /export/home/tjmoore/log100 'BEGIN {OFS="\t";} {print $1,$2,$3,$4,$5, $6,$7,$8,$9;}' > /export/home/tjmoore/log1001 I... (9 Replies)
Discussion started by: 02JayJay02
9 Replies

5. Shell Programming and Scripting

Issues with awk and tcsh

Hello experts, I have two files which I'm uploading. One is an awk script and other file acts as an input to the script via positional parameter. awk -f intlmenu.awk jobsq.txt This run fine in C shell on SCO OpenServer Release 5.0.7. When I run it on Solaris 10 ( tcsh shell ) I get... (2 Replies)
Discussion started by: maverick_here
2 Replies

6. Shell Programming and Scripting

Issues in reading file using 'awk'

Dear all, I am using following function of some script to assign variable "JobNo" some value form file $SAMPLE"_status.log" ( generated using the red color command ) crab ntuplize_crab -status -c $SAMPLE >& $SAMPLE"_status.log" & echo $SAMPLE"_status.log" "=====" jobNo=$(awk... (10 Replies)
Discussion started by: emily
10 Replies

7. Shell Programming and Scripting

Issues with executing awk

I am piping some output to awk and would like to print fields $1 $2 and $3 $4 only if they exist. Note the awk begins with awk '{print $NF " " since I want the last field printed first. (7 Replies)
Discussion started by: motdman
7 Replies

8. Shell Programming and Scripting

Email Format Output issues

Hi Guys, I have written a script, which output information from email notfication. The output works fine in HTML format, but non-html format it is not shown in a human readable format. Can you help with the format *** Script echo " Server Name : $CLIENT_CHECK "... (4 Replies)
Discussion started by: Junes
4 Replies

9. Shell Programming and Scripting

Command output redirection to file issues

Hi, I have a peculiar issue w.r.t redirecting the command output to a file when using loop. I am redirecting command output to same file in a series of if condition statements, but if one block of if condition statement writes the log to the file , the subsequent block of if condition... (7 Replies)
Discussion started by: ananan
7 Replies

10. Shell Programming and Scripting

Issues formatting output of two commands in a single line.

I wish to generate output of two commands in the same line separated by a single white-space. Below is my command and output in the same line. ls -ltr fname1.out | awk '{$2=$4=$5=x; print}' | tr '\n' '\t' | tr -s ' '; cksum<fname1.out | cut -d' ' -f1 Output: -rw-r--r--. root Aug 26 16:57... (6 Replies)
Discussion started by: mohtashims
6 Replies
cachefsstat(1M) 														   cachefsstat(1M)

NAME
cachefsstat - Cache File System statistics SYNOPSIS
path... ] DESCRIPTION
The command displays statistical information about the cache filesystem mounted on path. The statistical information includes cache hits and misses, consistency checking, and modification operations. If path is not specified, all mounted cache filesystems are used. can also be used to reinitialize this information (see description for the option). The statistical information has the following format: <cache hit rate> <consistency checks> <modifies> where each of the above is defined as: cache hit rate The percentage of cache hits over the total number of attempts followed by the actual numbers of hits and misses. consistency checks The number of consistency checks performed followed by the number that passed and the number that failed. modifies The number of modify operations, including writes, creates, and so on. Options recognizes the following option: Zero (reinitialize) statistics. Execute before executing again to gather statistics on the cache performance. This option can only be used by the supe- ruser. The statistics printed reflect those just before the statistics are reinitialized. RETURN VALUE
returns the following values: Success. non-zero An error occurred. EXAMPLES
AUTHOR
was developed by Sun Microsystems, Inc. SEE ALSO
cfsadmin(1M). cachefsstat(1M)
All times are GMT -4. The time now is 12:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy