Sponsored Content
Full Discussion: Processing files using awk
Top Forums Shell Programming and Scripting Processing files using awk Post 302453571 by rbmuruga on Wednesday 15th of September 2010 06:55:06 PM
Old 09-15-2010
Processing files using awk

Hi

I have files in our UNIX directory like the below
Code:
-rw-r--r--   1 devinfo    devsupp        872 Sep 14 02:09 IMGBTREE27309_12272_11_1_0_FK.idx0
-rw-r--r--   1 devinfo    devsupp        872 Sep 14 02:09 IMGBTREE27309_12272_11_0_0_PK.idx0
-rw-r--r--   1 devinfo    devsupp        432 Sep 14 02:09 IMGBTREE27309_12272_11_0.dat0
-rw-r--r--   1 devinfo    devsupp          0 Sep 14 02:09 IMGBTREE27309_12272_11_0.dat1
-rw-r--r--   1 devinfo    devsupp       8192 Sep 15 13:24 PMLKUP11200_35_0_27813H64.dat1
-rw-r--r--   1 devinfo    devsupp          0 Sep 15 13:24 PMLKUP11200_35_0_27813H64.idx1
-rw-r--r--   1 devinfo    devsupp        872 Sep 15 13:24 PMLKUP11200_35_0_27813H64.idx0
-rw-r--r--   1 devinfo    devsupp        432 Sep 15 12:44 PMLKUP11200_35_0_27794H64.dat0
-rw-r--r--   1 devinfo    devsupp        872 Sep 15 12:44 PMLKUP11200_35_0_27794H64.idx0
-rw-r--r--   1 devinfo    devsupp        432 Sep 15 13:24 PMJNR11200_52_0_27813.dat0
-rw-r--r--   1 devinfo    devsupp        872 Sep 15 13:24 PMJNR11200_52_0_27813.idx0
-rw-r--r--   1 devinfo    devsupp        872 Sep 15 12:44 PMJNR11200_52_0_27794.idx0
-rw-r--r--   1 devinfo    devsupp        432 Sep 15 12:44 PMJNR11200_52_0_27794.dat0

1. I want only the fields $6, $7, $8, $9 and $5
2. From the field $9, I do not need the extensions ie., I do not need .idx0, .dat0, .dat1 etc.,
3. Then group the files based on $9

So finally my output should look like the below
Code:

Sep 14 02:09 IMGBTREE27309_12272_11_1_0_FK      872
Sep 14 02:09 IMGBTREE27309_12272_11_0_0_PK      872
Sep 14 02:09 IMGBTREE27309_12272_11_0           432 
Sep 15 13:24 PMLKUP11200_35_0_27813H64         9044
Sep 15 12:44 PMLKUP11200_35_0_27794H64         1304
Sep 15 13:24 PMJNR11200_52_0_27813             1304
Sep 15 12:44 PMJNR11200_52_0_27794             1304

I have this script -
Code:
ls -l|awk '{arr[$9]+=$5} END {for (i in arr) {print i,arr[i]}}'

which will just give the total with extensions. After this I am stuck. Can someone please help me on this?

Last edited by Franklin52; 09-16-2010 at 03:32 AM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Preparing LaTeX files using Sed/AWK for processing with latex2html

As the title states, my issue involves preparing LaTeX documents for processing with latex2html. Within my LaTeX docs I have used a package which allows me to cleanly display source code listings. However the package is not supported by latex2html which, when processed, does not display the... (3 Replies)
Discussion started by: oski
3 Replies

2. Shell Programming and Scripting

awk processing

Hi all Is there a way in awk to know that you are processing your final line of input if you do no know how many lines were in the input to begin with? Thanks (7 Replies)
Discussion started by: pxy2d1
7 Replies

3. Shell Programming and Scripting

Writing output into different files while processing file using AWK

Hi, I am trying to do the following using AWK program. 1. Read the input data file 2. Parse the record and see if it contains errors 3. If the record contains errors, then write it into Reject file, else, write into usual output file or display it on the screen Here is what I have done -... (6 Replies)
Discussion started by: vidyak
6 Replies

4. UNIX for Dummies Questions & Answers

single output of awk script processing multiple files

Helllo UNIX Forum :) Since I am posting on this board, yes, I am new to UNIX! I read a copy of "UNIX made easy" from 1990, which felt like a making a "computer-science time jump" backwards ;) So, basically I have some sort of understanding what the basic concept is. Problem Description:... (6 Replies)
Discussion started by: Kasimir
6 Replies

5. Shell Programming and Scripting

get all files from a directory and pass the files for processing

Hi All, I have a directory in which there will be several files. i want to get all the files and pass it to a piece of code for processing on the files. This is the piece of code which does the processing. tr "\n" "|" < (log file name) | tr "$" "\n" > output echo ' ' >>output while... (1 Reply)
Discussion started by: suresh_kb211
1 Replies

6. Shell Programming and Scripting

awk script processing data from 2 files

Hi! I have 2 files containing data that I need to process at the same time, I have problems in reading a different number of lines from the different files. Here is an explanation of what I need to do (possibly with an awk script). File "samples.txt" contains data in the format: time_instant... (6 Replies)
Discussion started by: Alice236
6 Replies

7. Shell Programming and Scripting

processing with awk

I have many lines like the following in a file(there are also other kinds of lines) Host: 72.52.104.74 (tserv1.fmt2.he.net) Ports: 22/open/tcp//tcpwrapped///, 53/open/tcp//domain//PowerDNS 3.3/, 179/open/tcp//tcpwrapped/// Ignored State: closed (997) Seq Index: 207 IP ID Seq: All... (9 Replies)
Discussion started by: esolvepolito
9 Replies

8. Shell Programming and Scripting

Processing multiple files awk

hai i need my single awk script to act on 4 trace files of ns2 and to calculate througput and it should print result from each trace file in a single trace file. i tried with the following code but it doesnt work awk -f awkscript inputfile1 inputfile2 inputfile3 inputfile4>outputfile ... (4 Replies)
Discussion started by: sarathyy
4 Replies

9. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

10. Shell Programming and Scripting

Passing multiple files to awk for processing in bash script

Hi, I'm using awk command in bash script. I'm able to pass multiple files to awk for processing.The code i can use is as below(sample code) #!/bin/bash awk -F "," 'BEGIN { ... ... ... }' file1 file2 file3 In the above code i'm passing the file names manually and it is fine till my... (7 Replies)
Discussion started by: shree11
7 Replies
devinfo(1M)                                               System Administration Commands                                               devinfo(1M)

NAME
devinfo - print device specific information SYNOPSIS
/usr/sbin/devinfo -i device /usr/sbin/devinfo -p device DESCRIPTION
The devinfo command is used to print device specific information about disk devices on standard out. The command can only be used by the superuser. OPTIONS
-i Prints the following device information: o Device name o Software version (not supported and prints as 0) o Drive id number (not supported and prints as 0) o Device blocks per cylinder o Device bytes per block o Number of device partitions with a block size greater than zero -p Prints the following device partition information: o Device name o Device major and minor numbers (in hexadecimal) o Partition start block o Number of blocks allocated to the partition o Partition flag o Partition tag This command is used by various other commands to obtain device specific information for the making of file systems and determining parti- tion information. If the device cannot be opened, an error message is reported. OPERANDS
device Device name. EXIT STATUS
0 Successful operation. 2 Operation failed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
prtvtoc(1M), attributes(5) SunOS 5.10 8 May 1997 devinfo(1M)
All times are GMT -4. The time now is 11:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy