Sponsored Content
Full Discussion: grep sorting/formatting
Top Forums Shell Programming and Scripting grep sorting/formatting Post 302073316 by Jaken on Thursday 11th of May 2006 06:31:27 PM
Old 05-11-2006
grep sorting/formatting

Hi,

I currently have many log files for different webpages inside the folder /log/. The program allows the user to enter a month and then the grep function searches for it, the command i used is below:

grep -c "$month" ./log/*.log

This works and i can ascertain the number of matches, but I cannot find out how to format the name of the .log and the number of matches into two seperate columns. Kind of like:

Log Name Matches
--------------- --------

soccerscore.log 40
soccerfaqs 20

Any ideas how to do this?

At the moment its like

./logs/soccerscore.log:40

-Thanks for any help
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multiple Grep Results - Formatting

Hello, Perhaps someone here can help with this. I'd like to grep a plain text file for a word and output each line containing a word found to a seperate line instead of back to back. Examples: Basic command: cat file.txt > grep -i CAT > results.txt file.txt: The cat said meow The... (7 Replies)
Discussion started by: sysera
7 Replies

2. UNIX for Dummies Questions & Answers

Sorting using count, grep and count

Hi, I trying to sort information in a file by making count for every object. For example: A B A D A B C i would like to sort out count for each object (A's, B's and etc) but in actual case i dont know the object but i know the position ofthe object. do i need to use array as well? Any... (2 Replies)
Discussion started by: sukhpal_78
2 Replies

3. UNIX Desktop Questions & Answers

Grep result loses formatting

I am searching for a string in a file and then redirecting the contents in another file... however the formatting is not preserved.. Can you please help me on this ... (5 Replies)
Discussion started by: blackeyed
5 Replies

4. Shell Programming and Scripting

Output formatting of grep

hi, I am trying to find the word "root" from the follwoing sample file: #12.12.12.2222 echo "Hai........" 11.11.1.1111 3.23.AS.AA ab.cd.df.rf /usr/bin jhhh 12.12.AF.12 /urf/sss/kk kkk su sh.s exec su root; ,root sudo -sh cosrootex (3 Replies)
Discussion started by: flamingo_l
3 Replies

5. Shell Programming and Scripting

AWK/GREP sorting help

hi everyone, I am kind of new to this forum. I need help in sorting this data out accordingly, I am actually doing a traceroute application and wants my AS path displayed in front of my address like this; 192.168.1.1 AS28513 AS65534 AS5089 AS5089 .... till the last AS number and if possible sort... (8 Replies)
Discussion started by: sam127
8 Replies

6. Shell Programming and Scripting

Formatting list of IP addresses into a grep command

Hi I have an input file with a list of random IP addresses, each on a new line. Below is just an example as I omitted the real IP addresses for obvious reasons. Input: random_ip.txt 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1... (7 Replies)
Discussion started by: lewk
7 Replies

7. UNIX for Dummies Questions & Answers

GREP for sorting

Hi , I have a file which has a large number of sequences of type: gi_1 AASSKSKSKSSKSKSK.... series_121 DDKFKFKGKGKH gi_3 FFFFLFFLFLFLF series_1 DFFFFFF pattern_3 GEEEEEEEEE gi_2 HKKGGKGKGK series_102 HHHHH pattern_1 (2 Replies)
Discussion started by: siya@
2 Replies

8. Homework & Coursework Questions

Shell Script: Sorting by column using grep/awk

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: You will write a script that will read a tab-separated file that contains the names of all 50 states &... (7 Replies)
Discussion started by: tburns517
7 Replies

9. Shell Programming and Scripting

Formatting grep and awk output

Hi there. I have a very large file and I am trying to format it so that I can pull out certain pieces of data/info and report it in spreadsheet format/style. The file has ###### which will separate each line that will be listed in the spreadsheet. Whenever I find "No" at the end of a line I want... (7 Replies)
Discussion started by: kieranfoley
7 Replies

10. Shell Programming and Scripting

GREP Formatting Question

I have the following nmap file output with the multiple IP’s listed in the format below. Is there a way that GREP can format the output to just display IP and any ports that contain 'http' for that IP on its own line? file: Host: 192.168.1.xxx () Ports: 80/open/tcp//http///,... (3 Replies)
Discussion started by: FCoda10
3 Replies
FANN_READ_TRAIN_FROM_FILE(3)						 1					      FANN_READ_TRAIN_FROM_FILE(3)

fann_read_train_from_file - Reads a file that stores training data

SYNOPSIS
resource fann_read_train_from_file (string $filename) DESCRIPTION
Reads a file that stores training data. PARAMETERS
o $filename - The input file in the following format: num_train_data num_input num_output inputdata seperated by space outputdata seperated by space inputdata seperated by space outputdata seperated by space RETURN VALUES
Returns a train data resource on success, or FALSE on error. EXAMPLES
Example #1 fann_read_train_from_file example <?php $train_data = fann_read_train_from_file("xor.data"); if ($train_data) { // Do something with $train_data for XOR function } ?> Contents of xor.data 4 2 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1 SEE ALSO
fann_train_on_data(3), fann_destroy_train(3), fann_save_train(3). PHP Documentation Group FANN_READ_TRAIN_FROM_FILE(3)
All times are GMT -4. The time now is 06:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy