Shell script to search all files for every string in another file
Hello All
I have a pattern.txt file in source directory ((/project/source/) in linux server and data looks like:
I have multiple log files in log directory (/project/log/) in linux server and data for one log file looks like:
I want to grep every single string in the source file - pattern.txt against all log files in log directory
and populate the output in a output.txt file in directory (/project/output/) data should look like below:
If a string is matched against any log file, I want to check if line starts with '<?xml version' then i want to populate second line also in the output file along with matching line
otherwise I just want to populate the matching line.
Please help me in writing a unix command / shell script to achieve it.
Last edited by Scrutinizer; 11-09-2016 at 08:37 PM..
Reason: code tags
I need to count the number of files which have a search string, but counting the file only once
if search string is found.
eg: File1: Please note that there are 2 occurances of "aaa"
aaa
bbb
ccc
aaa
File2: Please note that there are 3 occurances of "aaa"
aaa
bbb
ccc... (1 Reply)
Hi,
I've a shell script e.g.
#!/bin/bash
echo "Enter the next hop id"
read nhid
echo "enter the IP address"
read IP
echo "enter the interface name"
read name
echo "enter the enable/disable state"
read state
exit 0
now from this script i want to search strings in another (.cam)
... (6 Replies)
Hi,
We Perfrom Loads to the database through a Perl script which generates a statistics file. I need to read the statistics. the Statistics file looks something like below:
Process Beginning - 08-26-2010-23.41.47
DB2 CONNECTION SUCCESSFUL!
Ready to process and load file: FILENAME
# of... (2 Replies)
Have to read one file say sourcefile containing several words and having another folder containing several files.
Now read the first word of Sourcefile & search it into the folder consisting sevral files, and create another file with result. We hhave to pick the filename of the file in which... (3 Replies)
Hi,
I am trying to create a shell script in unix platform, hence will need info on how to start and any ideas from you guys. million thx.
Objective: Shell script to search all entries from 1 file(a.out) to all other files and extract the search output to 1 file (c.out).
Situation,
1)... (8 Replies)
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
All,
i have a file text.log:
cover6
cover3
cover2
cover4
other file is abc.log as :
0
0
1
0
Then I have a excel file result.xls that contains:
Name Path Pass
cover2
cover3
cover6
cover4 (1 Reply)
Hi folks,
I am new for shell script, I hope somebody to help me to write shell script
My requirement is below steps
1. I have apache access.log i.e located in /var/log/httpd/
Ex.
127.0.0.1 - - "GET... (14 Replies)
So, there is a large file where I have to conduct several search using bash shell scripting.
The file is like this:
TITLE and AUTHOR ETEXT NO. Aspects of plant life; with special reference to the British flora, 56900 by Robert Lloyd... (1 Reply)
I have a text file which is generated when the batch job is run. This batch may take few mins to run. When completed, the last line of the text file would be process completed. I need a shell script which will wait for this file till the process completed is printed in it, once found, it would move... (2 Replies)
Discussion started by: Lalat
2 Replies
LEARN ABOUT OSF1
nislog
nislog(1M) System Administration Commands nislog(1M)NAME
nislog - display the contents of the NIS+ transaction log
SYNOPSIS
/usr/sbin/nislog [-h num | -t num] [-v] [directory...]
DESCRIPTION
nislog displays the contents of the NIS+ server transaction log on the standard output. This command can be used to track changes in the
namespace. The /var/nis/trans.log file contains the transaction log maintained by the NIS+ server. When updates occur, they are logged to
this file and then propagated to replicas as log transactions. When the log is checkpointed, updates that have been propagated to the
replicas are removed.
The nislog command can only be run on an NIS+ server by superuser. It displays the log entries for that server only.
If directory is not specified, the entire log is searched. Otherwise, only those logs entries that correspond to the specified directories
are displayed.
OPTIONS -h num Display num transactions from the ``head'' of the log. If the numeric parameter is 0, only the log header is displayed.
-t num Display num transactions from the ``tail'' of the log. If the numeric parameter is 0, only the log header is displayed.
-v Verbose mode.
FILES
/var/nis/trans.log transaction log
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWnisu |
+-----------------------------+-----------------------------+
SEE ALSO nis+(1), rpc.nisd(1M), nisfiles(4), attributes(5)NOTES
NIS+ might not be supported in future releases of the SolarisTM Operating Environment. Tools to aid the migration from NIS+ to LDAP are
available in the Solaris 9 operating environment. For more information, visit http://www.sun.com/directory/nisplus/transition.html.
SunOS 5.10 12 Dec 2001 nislog(1M)