Sponsored Content
Top Forums Shell Programming and Scripting Searching multiple files with multiple expressions Post 45957 by Anahka on Tuesday 6th of January 2004 01:16:56 PM
Old 01-06-2004
Question Searching multiple files with multiple expressions

I am using a DEC ALPHA running Digital UNIX (formly DEC OSF/1) and ksh. I have a directory with hundreds of files that only share the extension .rpt. I would like to search that directory based on serial number and operation number and only files that meet both requirements to be printed out. I am new to scripting and have been try to do this with grep but have not had much luck.

here is a sample of the file: (120205462.rpt)
_________________________________
S/N: 10001 Name: ESSM GS Acceptance Operation: 300
-----------------------------------------------------
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Searching for multiple criteria in log files?

I would like a simple shell script that will allow me to display to screen all unsuccessful su attempts in my sulog file, for the present date. I have been trying several different combinations of commands, but I can't quite get the syntax correct. The mess I have right now (don't laugh) is... (4 Replies)
Discussion started by: Relykk
4 Replies

2. Shell Programming and Scripting

Searching for multiple patterns in files

I have a situation where I need to search for multiple strings (error messages) such as 'aborted' 'file not found' etc in directory having logs. I have put all the error messages in a text file and using the command. grep -f <textfile> <filetobegrepped> I'm doing this thru a script where I... (5 Replies)
Discussion started by: bornon2303
5 Replies

3. Shell Programming and Scripting

Perl, searching multiple files and printing returned line to new file

I am trying to find a way to utilise the full potential of my cpu cores and memory on my windows machine. Now, I am quite familiar with grep, however, running a Unix based OS is not an option right now. Unfortunately, the 32 bit grep for windows that I am running, I cannot run multiple... (1 Reply)
Discussion started by: Moloch
1 Replies

4. Shell Programming and Scripting

Searching a word in multiple files

Hi All, I have a issue in pulling some heavy records , I have my input file has 10,000 records which i need to compare with daily appended log files from (sep 1st 2009 to till date) . I tried to use grep fgrep and even sed , but the as time is factor for me , i cannot wait for 5 days to get the... (3 Replies)
Discussion started by: rakesh_411
3 Replies

5. Shell Programming and Scripting

Searching across multiple files if pattern is available in all files searched

I have a list of pattern in a file, I want each of these pattern been searched from 4 files. I was wondering this can be done in SED / AWK. say my 4 files to be searched are > cat f1 abc/x(12) 1 abc/x 3 cde 2 zzz 3 fdf 4 > cat f2 fdf 4 cde 3 abc 2... (6 Replies)
Discussion started by: novice_man
6 Replies

6. Shell Programming and Scripting

Nawk help searching for multiple lines and multiple searches

I use this command to find a search (Nr of active alarms are) and print one line before and 10 lines after the search keywords. nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=1 a=10 s="Nr of active alarms are:" *.log However, I would like to know how to tell it to print... (3 Replies)
Discussion started by: tthach830
3 Replies

7. UNIX for Dummies Questions & Answers

Grep in Perl - Searching through multiple files

I'm attempting to use grep in Perl with very little success. What I would like to do in Perl is get the output of the following grep code: grep -l 'pattern' * This gives me a list of all the files in a directory that contain the pattern that was searched. My attempts to do this in Perl... (4 Replies)
Discussion started by: WongSifu
4 Replies

8. Shell Programming and Scripting

Searching for similar row(s) across multiple files

Hello Esteemed Members, I need to write a script to search for files that have one or more than one rows similar. Please note that there is no specific pattern that I am searching for. The rows can be different, I just need to find out two or more similar records in two or more files. There... (7 Replies)
Discussion started by: Yoodit
7 Replies

9. Shell Programming and Scripting

Help on searching for a string on multiple files

Hi all, I am sure some gurus will find a better way of doing this. FYI, I've manually modified some of the data 'coz they are somewhat confidential, so there may be some typo errors. At the moment, I have 3 files that I am trying to search for. Sometime in the future, it may go beyond 3... (2 Replies)
Discussion started by: newbie_01
2 Replies

10. BSD

Searching in multiple files

I am new to unix and I would like to search multiple log files to find earliest occurrence of a text. Ex: Say I have 10 logs file each ending with .log and I want to find the text “CustomeError” . I want to find the which log file “CustomeError” comes first and lines which surround’s ... (4 Replies)
Discussion started by: jim john
4 Replies
acctmerg(8)						      System Manager's Manual						       acctmerg(8)

NAME
acctmerg - Merges total-accounting files into an intermediary file or a daily accounting file SYNOPSIS
acctmerg -[ahipv] [specification] -[tu] [file ....] FLAGS
Produces output as ASCII records. Lists column headings. This flag implies -a but is effective with the -p or -v flags. Expects input files to have ASCII records that are converted to binary output records. Lists input but without processing. Produces a single record that contains the totals of all input. Summarizes by user ID rather than by user name. This is convenient when a single user ID is allo- cated to more than one user name. Produces output in ASCII, with more precise notation for floating-point values. DESCRIPTION
The acctmerg command combines process, connect time, fee, disk usage, and queuing (printer) total-accounting records in tacct binary or tacct ASCII format (see the tacct structure in the acct.h file format for a description of this total-accounting format). The acctmerg com- mand writes the results of record processing to standard output. The accounting file produced by the acctmerg command may have entries for as many as 18 columns. Column headings are printed only when you use the -h flag. The following table lists the column headings by number, the column heading by label, and the purpose of the entry: User ID. This is the integer value of the user ID from the /etc/passwd file. User login name. This is the alpha user login name from the /etc/passwd file. Prime-time CPU run time. This is the total time in seconds that prime-time CPU run time was charged to the user during the active accounting period. Nonprime-time CPU run time. This is the total time in seconds that nonprime-time CPU run time was charged to the named user. Prime-time memory K-core. This is a measure of memory usage during prime time. This value expresses the amount of memory used and the elapsed amount of prime time during which it was used (K-core is the product of total CPU time in minutes and mean size of memory used). Nonprime-time memory K-core. This is a measure of memory usage during nonprime time. Prime-time read and write characters. This is the total number of characters transferred during prime-time opera- tion. Nonprime-time read and write characters. This is the total number of characters transferred during nonprime-time operation. Prime- time number of I/O blocks. This is the total number of I/O blocks transferred during prime-time read and write operations. The number of bytes in an I/O block is implementation dependent. Nonprime-time number of I/O blocks. This is the total number of I/O blocks transferred during nonprime-time read and write operations. Prime-time connect duration. This is the total number of prime-time seconds during which a connection existed. Nonprime-time connect duration. This is the total number of nonprime-time seconds during which a connection existed. Disk blocks used. This is the total number of disk blocks used. Number of pages printed. This is the total number of pages queued to any printers in the system. Special fee charge units. This is the number of integer units to charge for any special fee. This value is the one supplied when the /usr/sbin/acct/chargefee command is processed during the active accounting period. Number of processes. This is the total number of processes spawned by the user during the active accounting period. Number of logins. This is the total number of times the user logged in during the active accounting period. Number of disk-accounting samples. This is the total number of times during the active accounting period that the disk-accounting command was used to get the total number of disk blocks listed in the DSK_BLOCKS column. When the value in the DSK_BLOCKS column is divide by this number, the average number of disk blocks used during the accounting period is obtained. Total accounting records are read from standard input and any additional files (up to nine) you specify with the file parameter. File records are merged according to identical keys, usually the user ID and user login name. To optimize processing performance, output is written in binary, unless the -a or -v flag is used. Normally the acctmerg command is called from the runacct shell procedure, either to produce an intermediate file (/var/adm/acct/nite/daytacct, for example) when one or more source accounting files is full, or to merge intermediate files into a cumula- tive total (/var/adm/acct/sum/tacct, is another example). The cumulative total daily files are the source from which the monacct command produces an ASCII monthly summary file, which is written to the /var/adm/acct/fiscal subdirectory. The optional specification parameter allows you to select input or output column entries, as illustrated in Example 1. Field specifications are a comma-separated string of field numbers. Field numbers are referenced in boldface type in the first column of the foregoing list together with their respective column headings. When you specify field numbers they should be listed in the order specified by the bold- faced heading reference numbers. Inclusive field ranges may also be specified, with array sizes properly taken into account except for the ta_name number of characters. For example, -h2-3,11,15-13,2 displays the LOGNAME (2), PRI_CPU (3), PRI_CONNECT time (11), FEES (15), PRINT (14), DISK_BLOCKS (13), and again LOGNAME (2), in that order, with the described column headings (-h). The default specification is to output all 18 columns (1-18 or 1-), which produces rather wide output records that contain all the available accounting data. Queuing system, disk usage, or fee data can be converted into tacct records with the acctmerge command, using the -i flag and the specifi- cation parameter. EXAMPLES
To merge inclusive fields from an ASCII disk-accounting file called dacct into an existing total-accounting file named tacct as binary information, but with entries for fields 1, 2, 13, and 18 only, enter the following line: acctmerg -i 1 -2,13,18 <dacct | acctmerg tacct >output The acctmerg command reads the columnar entries for UID (1), LOGNAME (2), DSK_BLOCKS (13), and DSAMPS (18) from the dacct file as input, merges this information as tacct binary records, and writes the result to standard output as ASCII. To repair file jan2.rpt in inclusive tacct columnar format, enter the following initial command, edit the jan2.tmp file, and then enter the last command: acctmerg -v <jan2.rpt >jan2.tmp Edit jan2.tmp as desired.... acctmerg -i >jan2.tmp >jan2.rpt The first command redirects the content of file jan2.rpt to file jan2.tmp, with ASCII output and floating-point values. After you edit file jan2.tmp, the last command redirects file jan2.tmp as ASCII input to file jan2.rpt as output, with output records in binary. FILES
Specifies the command path. Accounting header files that define formats for writing accounting files. This is where prime time is set. Intermediate daily total-accounting file. Cumulative total-accounting file. RELATED INFORMATION
Commands: acct(8), acctcms(8), acctcom(8), acctcon(8), acctdisk(8), acctprc(8), fwtmp(8), runacct(8), wtmpconvert(8). Functions: acct(2). delim off acctmerg(8)
All times are GMT -4. The time now is 04:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy