Sponsored Content
Top Forums Shell Programming and Scripting Find keywords in multiple log files Post 302974894 by Scrutinizer on Sunday 5th of June 2016 08:15:13 PM
Old 06-05-2016
There seem to be multiple issues with this code:
  • there is semicolon missing between the first two gsubs, is that a typo?
  • also the third gsub seems to have a spurious v=$2 in it, and if you leave that out it becomes identical to the the first gsub, so the third serves no purpose
  • There is a single quote missing at the end of the awk statements
  • In the field separators specification -F '[= '':;.]' the two quotes in the middle serve no purpose. Also also it seems ill adapted to splitting fields of the input file. With the given input $1 will only ever contain "MEMSIZE" and so that is the only time that the $1 in L condition is true, but then $2 is empty, but since the label in array L is "MEMORIZE " with a trailing space, even that will not match.
  • K[2]>'5:00:00' contains single quotes instead of double quotes, so this evaluates to K[2]>5:00:00, which is a syntax error

Last edited by Scrutinizer; 06-05-2016 at 10:13 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find particular string in multiple files

Hello friends, I have find a paticular string from the files present in my user for example: a username and password is hardcoded in multiple files which present in the my user.so I have to search about username in which files it is available.there are several dirctories are there,so... (5 Replies)
Discussion started by: sivaranga001
5 Replies

2. Shell Programming and Scripting

Finding 50k Keywords in 3k files

Hi, I have a file with about 50k keywords. I have a requirement to scan about 3k files to identify which filename has which keyword i.e. an output like following: File1,Keyword1 File1,Keyword2 File3,Keyword1 ..... I have written a shell script which takes each of the 3k files, searches... (4 Replies)
Discussion started by: rjains
4 Replies

3. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

4. UNIX for Dummies Questions & Answers

finding keywords in many files using grep

Hi to all Sorry for the confusion because I did not explain the task clearly. There are many .hhr files in a folder There are so many lines in these .hhr files but I want only the following 2 lines to be transferred to the output file. The keyword No 1 and all the words in the next line They... (5 Replies)
Discussion started by: raghulrajan
5 Replies

5. UNIX for Advanced & Expert Users

Need to search for keywords within files modified at a certain time

I have a huge list of files in an Unix directory (around 10000 files). I need to be able to search for a certain keyword only within files that are modified between certain date and time, say for e.g 2012-08-20 12:30 to 2012-08-20 12:40 Can someone let me know what would be the fastest way... (10 Replies)
Discussion started by: virtual123
10 Replies

6. Shell Programming and Scripting

Find keywords, and append at the end of line

Task: Find keywords in each line, and append at the end of line; if not found in the line, do nothing. the code is wrong. how to make it work. thanks a lot. cat keywords.txt | while read line; do awk -F"|" '{if (/$line/) {print $0"$line , ";} else print;}' outfile.txt > tmp ... (9 Replies)
Discussion started by: dtdt
9 Replies

7. Shell Programming and Scripting

Search files in directory for keywords using bash

I have ~100 text files in a directory that I am trying to parse and output to a new file. I am looking for the words chr,start,stop,ref,alt in each of the files. Those fields should appear somewhere in those files. The first two fields of each new set of rows is also printed. Since this is on a... (7 Replies)
Discussion started by: cmccabe
7 Replies

8. UNIX for Dummies Questions & Answers

Find keywords in multiple log files

The Problem that I am having is when the code ran and populated the progflag.csv file, columns MEMSIZE, SECOND and SASEXE were blank. The next problems are the IF else statement isn't working and the email function isn't sending the progflag.csv attachment. a. What I want the program to do is to... (2 Replies)
Discussion started by: dellanicholson
2 Replies

9. Shell Programming and Scripting

Grep multiple keywords from a file

I have a script that will search for a keyword in all the log files. It work just fine. LOG_FILES={ "/Sandbox/logs/*" } for file in ${LOG_FILES}; do grep $1 $file done This only works for 1 keyword. What if I want to search for more then 1 keywords, say 4 or maybe even... (10 Replies)
Discussion started by: Loc
10 Replies

10. UNIX for Beginners Questions & Answers

Find and replace from multiple files

Hello everybody, I need your help. I have a php site that was expoited, the hacker has injected into many php files a phishing code that was discovered and removed in order to have again a clean code. Now we need to remove from many php files that malware. I need to create a script that find and... (2 Replies)
Discussion started by: ninocap
2 Replies
prs(1)							      General Commands Manual							    prs(1)

Name
       prs - display information from an SCCS file

Syntax
       prs [-d[dataspec]] [-r[SID]] [-e] [-l] [-a] files

Description
       The command prints on the standard output all or parts of an SCCS file in a user supplied format.  For further information, see If a direc-
       tory is named, behaves as though each file in the directory were specified as a named file, except that non-SCCS files (last  component	of
       the  path  name	does  not begin with s.), and unreadable files are silently ignored.  If a name of - is given, the standard input is read;
       each line of the standard input is taken to be the name of an SCCS file or directory to be processed; non-SCCS files and  unreadable  files
       are silently ignored.

       Arguments to which may appear in any order, consist of keyletter arguments, and file names.

Options
       All the described keyletter arguments apply independently to each named file:

       -a		   Displays printing of information for both removed and existing deltas.  For example, removed delta type = R, and exist-
			   ing delta type = D.	For further information, see If the -a keyletter is not specified, information	is  provided  only
			   for existing deltas.

       -d[dataspec]	   Displays  information  specified by dataspec.  The dataspec is a string consisting of SCCS file data keywords (see DATA
			   KEYWORDS) interspersed with optional user-supplied text.

       -e		   Displays information for all deltas created earlier than and including the delta designated by the -r keyletter.

       -l		   Displays information for all deltas created later than and including the delta designated by the -r keyletter.

       -r[SID]		   Indicates delta version number.  If no SID is specified, the SID of the most recently created delta is assumed.

Data Keywords
       Data keywords specify which parts of an SCCS file are to be retrieved and printed on the standard output.  All parts of an SCCS	file  have
       an associated data keyword.  For further information, see There is no limit on the number of times a data keyword may appear in a dataspec.

       The information printed by consists of the user supplied text and the appropriate values (extracted from the SCCS file) substituted for the
       recognized data keywords in the order of appearance in the dataspec.  The format of a data keyword value is either  Simple  (S),  in  which
       keyword substitution is direct, or Multi-line (M), in which keyword substitution is followed by a carriage return.

       User  supplied text is any text other than recognized data keywords.  A tab is specified by 	 and carriage return/new-line is specified by
       
.

							Table 1. SCCS Files Data Keywords
			      Keyword Data Item 			      File Section	 Value	     Format
			       :Dt:   Delta Information 		      Delta Table     See below*       S
			       :DL:   Delta line statistics			  "	    :Li:/:Ld:/:Lu:     S
			       :Li:   Lines inserted by Delta			  "		 nnnnn	       S
			       :Ld:   Lines deleted by Delta			  "		 nnnnn	       S
			       :Lu:   Lines unchanged by Delta			  "		 nnnnn	       S
			       :DT:   Delta type				  "		D or R	       S
			       :I:    SCCS ID string (SID)			  "	    :R:.:L:.:B:.:S:    S
			       :R:    Release number				  "		 nnnn	       S
			       :L:    Level number				  "		 nnnn	       S
			       :B:    Branch number				  "		 nnnn	       S
			       :S:    Sequence number				  "		 nnnn	       S
			       :D:    Date Delta created			  "	    :Dy:/:Dm:/:Dd:     S
			       :Dy:   Year Delta created			  "		  nn	       S
			       :Dm:   Month Delta created			  "		  nn	       S
			       :Dd:   Day Delta created 			  "		  nn	       S
			       :T:    Time Delta created			  "	    :Th:::Tm:::Ts:     S
			       :Th:   Hour Delta created			  "		  nn	       S

			       :Tm:   Minutes Delta created			  "		  nn	       S
			       :Ts:   Seconds Delta created			  "		  nn	       S
			       :P:    Programmer who created Delta		  "		logname        S
			       :DS:   Delta sequence number			  "		 nnnn	       S
			       :DP:   Predecessor Delta seq-no. 		  "		 nnnn	       S
			       :DI:   Seq-no. of deltas incl., excl., ignored	  "	    :Dn:/:Dx:/:Dg:     S
			       :Dn:   Deltas included (seq #)			  "	     :DS: :DS:...      S
			       :Dx:   Deltas excluded (seq #)			  "	     :DS: :DS:...      S
			       :Dg:   Deltas ignored (seq #)			  "	     :DS: :DS:...      S
			       :MR:   MR numbers for delta			  "		 text	       M
			       :C:    Comments for delta			  "		 text	       M
			       :UN:   User names			       User names	 text	       M
			       :FL:   Flag list 				 Flags		 text	       M
			       :Y:    Module type flag				  "		 text	       S
			       :MF:   MR validation flag			  "	       yes or no       S
			       :MP:   MR validation pgm name			  "		 text	       S
			       :KF:   Keyword error/warning flag		  "	       yes or no       S
			       :KV:   Keyword validation string 		  "		 text	       S
			       :BF:   Branch flag				  "	       yes or no       S
			       :J:    Joint edit flag				  "	       yes or no       S
			       :LK:   Locked releases				  "		:R:...	       S
			       :Q:    User-defined keyword			  "		 text	       S
			       :M:    Module name				  "		 text	       S
			       :FB:   Floor boundary				  "		  :R:	       S
			       :CB:   Ceiling boundary				  "		  :R:	       S
			       :Ds:   Default SID				  "		  :I:	       S
			       :ND:   Null delta flag				  "	       yes or no       S
			       :FD:   File descriptive text			Comments	 text	       M
			       :BD:   Body					  Body		 text	       M
			       :GB:   Gotten body				  "		 text	       M
			       :W:    A form of what (1) string 		  N/A	       :Z::M::I:       S
			       :A:    A form of what (1) string 		  N/A	   :Z::Y: :M: :I::Z:   S
			       :Z:    what (1) string delimiter 		  N/A		 @(#)	       S
			       :F:    SCCS file name				  N/A		 text	       S
			       :PN:   SCCS file path name			  N/A		 text	       S

	  *:Dt: = :Dt: :I: :D: :T: :P: :DS: :DP:

Examples
       The following is an example of a command line and what it produces on the standard output:
       prs -d"Users and/or user IDs for :F: are:
:UN:" s.file

	      Users and/or user IDs for s.file are:
	      xyz
	      131
	      abc

       This is another example and its output.
       prs -d"Newest delta for pgm :M:: :I: Created :D: By :P:" -r s.file

	      Newest delta for pgm main.c: 3.7 Created 77/12/1 By case

       This is an example of a special case:
       prs s.file

       This is what it may produce on the standard output:

	      D 1.1 77/12/1 00:00:00 cas 1 000000/00000/00000 MRs: bl78-12345 bl79-54321 COMMENTS: this is the comment	line  for  s.file  initial
	      delta  for each delta table entry of the ``D'' type.  The only keyletter argument allowed to be used with the special case is the -a
	      keyletter.

Diagnostics
       See for explanations.

Files
       /tmp/pr?????

See Also
       admin(1), delta(1), get(1), help(1), sccs(1), sccsfile(5)
       Guide to the Source Code Control System

																	    prs(1)
All times are GMT -4. The time now is 03:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy