Need help to grep every character in a file against multiple files
Hello All I am trying to grep the list of id's in a .txt file(patterns.txt) against all log files which are in /logs directory in a server. Patterns.txt file has only ID's, that means I need to search for each and every character. Please help me how it can be done.
There are several ways to interpret your request that would lead to wildly different suggestions.
Please tell us what operating system and shell you're using.
Please show us (in CODE tags) sample patterns.txt file contents.
Please show us (in CODE tags) sample contents of a couple of files in the /logs directory.
Please show us (based on the above two requests) exactly what output you're hoping to produce (in CODE tags).
And please let us know where patterns.txt is located and what the name are for the files in /logs that are to be searched.
Will you b e running this script on the server containing the /logs directory? If not, what is the server's name and how do you plan to access files from that server?
1.Please tell us what operating system and shell you're using.
Linux Box and i need SH script
2. Please show us (in CODE tags) sample patterns.txt file contents.
patterns.txt file looks like below
3. Please show us (in CODE tags) sample contents of a couple of files in the /logs directory.
Here is one of the sample log file, all log files has the same data format
4. Please show us (based on the above two requests) exactly what output you're hoping to produce (in CODE tags).
Since we have only 1 match, I want output to be populated in seperate output file output.txt
5. And please let us know where patterns.txt is located and what the name are for the files in /logs that are to be searched.
patterns.txt is located in directory /home/userid
I want all the files in /logs to be searched, there are 10 files in this directory and the file name in /logs directory looks like klm_debug_0107.log
6. Will you b e running this script on the server containing the /logs directory? If not, what is the server's name and how do you plan to access files from that server?
Yes, I will be running on the same server
Last edited by Scrutinizer; 01-07-2016 at 04:32 PM..
Reason: code tags
Hi Gurus,
I got a small requirement in my script to grep a specific pattern in a zip compressed file which has been created with multiple files.
Sample File: 20180913.zip
$> zipinfo -l 20180913.zip
20180913_file1
20180913_file2
20180913_file3
20180912_file4
20180912_file5... (1 Reply)
Hi All,
I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results.
#!/bin/ksh
(
a="/path/file1"
b="path/file2"
for file in... (4 Replies)
Hi,
I want to grep multiple patterns from multiple files and save to multiple outputs. As of now its outputting all to the same file when I use this command.
Input : 108 files to check for 390 patterns to check for. output I need to 108 files with the searched patterns.
Xargs -I {} grep... (3 Replies)
Hi,
I have a file containing list of strings like
i:
Pink
Yellow
Green
and I have file having list of file names in a directory
j :
a
b
c
d
Where j contains of a ,b,c,d are as follows
a:
Pink (3 Replies)
Hi, every one!
I have a file with multiple strings.
file1
ATQRGNE
ASQGVKFTE
ASSQYRDRGGLET
SPEQGARSDE
ASSRDFTDT
ASSYSGGYE
ASSYTRLWNTGE
ASQGHNTD
PSLGGGNQPQH
SLDRDSYNEQF
I want to grep each string in hundreds of files in the same directory, further, I want to find out the string... (7 Replies)
Hi
I'm sure there's a way to do this, but I ran out of caffeine/talent before getting the answer in a long winded alternate way (don't ask ;) )
The task I was trying to do was scan a directory of files and show only files that contained 3 values:
I940
5433309
2181
I tried many variations... (4 Replies)
Hi,
I will use below command for grep single string ("osuser" is search string)
ex: find . -type f | xarg grep -il osuser
but i have one more string "v$session"
here i want to grep in which file these two strings are present.
any help is appreciated,
Thanks in advance.
Gagan (2 Replies)
I am new to shell scripting, and need a script to randomly distribute each character from a file into one of three new files. I also need each character to maintain it's position from the original file in the new file (such that if a character is written to File 1, Files 2 and 3 have spaces... (10 Replies)
I have a couple of things I got stuck on
1)
I have a text file containing 25k search string that I need to search against compressed file. I have used this command but somehow it doesn't seems to use all the search terms.
I have put one search string per line in the txt file (I clean up... (2 Replies)
How do I use the grep command to take mutiple text files in a folder and make one huge text file out of them. I'm using Mac OS X and can not find a text tool that does it so I figured I'd resort to the BSD Unix CLI for a solution... there are 5,300 files that I want to write to one huge file so... (7 Replies)