Sponsored Content
Top Forums Shell Programming and Scripting Extracting a string from one file and searching the same string in other files Post 302136648 by SanjayLinux on Wednesday 19th of September 2007 03:17:59 AM
Old 09-19-2007
Hammer & Screwdriver Try This one

Let say you have file1 without delimeter and you want first 10 char as pattern to search in another files.

#!/bin/sh
cut -c1-10 file1 >pattern.txt
for pattern in `cat pattern.txt`
do
find $pattern file_name1 file_name2
done
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Searching for files with certain string pattern

Hello All I would like to search for files containing certain string pattern under all the directories under /vobs/vobname and print the output to a file in my home directory. How can I do this? Note: /vobs/vobname conatins several directories. Thank You in advance newbetounix (1 Reply)
Discussion started by: intrigue
1 Replies

2. UNIX for Dummies Questions & Answers

searching for a string in a file

I need to search for a specific string in a file and if this string exist I need to replace it with something else. I am not sure how I could do this, using an if statement. (2 Replies)
Discussion started by: ROOZ
2 Replies

3. Shell Programming and Scripting

Extracting particular string in a file and storing matched string in output file

Hi , I have input file and i want to extract below strings <msisdn xmlns="">0492001956</ msisdn> => numaber inside brackets <resCode>3000</resCode> => 3000 needs to be extracted <resMessage>Request time getBalances_PSM.c(37): d out</resMessage></ns2:getBalancesResponse> => the word... (14 Replies)
Discussion started by: sushmab82
14 Replies

4. Shell Programming and Scripting

searching each file for a string

Hi Guys... I want to search for each file that contains a particular string. e.g find . -print | xargs grep -i string_name Now my issue is the files that I search in are gzipped. Will I be able to find the string, using the above commands, even if the files are gzipped? Please... (2 Replies)
Discussion started by: Phuti
2 Replies

5. Shell Programming and Scripting

searching the required string and appending string to it.

Hi all, I have some data in the form of adc|nvhs|nahssn|njadnk|nkfds in the above data i need to write a script so thet it will append "|||" to the third occurnace in the string ..... the outout should look like adc|nvhs|nahssn||||njadnk|nkfds Thanks, Firestar. (6 Replies)
Discussion started by: firestar
6 Replies

6. Shell Programming and Scripting

Using columns from 2 files and extracting string

Hi All, I have 2 files with a common column. File 1 looks like NAME START POS1 POS2 N1 1234 1236 1237 N2 1245 1248 1250 .. .. File 2 looks like NAME STRING N1 ABCDEFGH N2 EFGHBCD N3 PQRSSTUV .. ...... ... (25 Replies)
Discussion started by: alpesh
25 Replies

7. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

8. Shell Programming and Scripting

Searching a particular string pattern in 10000 files

Problem Statement:- I need to search a particular `String Pattern` in around `10000 files` and find the records which contains that `particular pattern`. I can use `grep` here, but it is taking lots of time. Below is the command I am using to search a `particular string pattern` after... (3 Replies)
Discussion started by: raihan26
3 Replies

9. Shell Programming and Scripting

Grep string in files and list file names that contain the string

Hi, I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat. My OS is: SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Discussion started by: apenkov
8 Replies

10. 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
TFBS::PatternGen(3pm)					User Contributed Perl Documentation				     TFBS::PatternGen(3pm)

NAME
TFBS::PatternGen - a base class for pattern generators DESCRIPTION
TFBS::PatternGen is a base classs providing methods common to all pattern generating modules. It is meant to be inherited by a concrete pattern generator, which must have its own constructor. pattern Title : pattern Usage : my $pattern_obj = $patterngen->pattern() Function: retrieves a pattern object produced by the pattern generator Returns : a pattern object (currently available pattern generators return a TFBS::Matrix::PFM object) Args : none Warning : If a pattern generator produces more than one pattern, this method call returns only the first one and prints a warning on STDERR, In those cases you should use I<all_patterns> or I<patternSet> methods. patternSet Title : patternSet Usage : my $patternSet = $patterngen->patternSet() Function: retrieves a pattern set object containing all the patterns produced by the pattern generator Returns : a pattern set object (currently available pattern generators return a TFBS::MatrixSet object) Args : none all_patterns Title : all_patterns Usage : my @patterns = $patterngen->all_patterns() Function: retrieves an array of pattern objects produced by the pattern generator Returns : an array of pattern set objects (currently available pattern generators return an array of TFBS::Matrix::PFM objects) Args : none perl v5.14.2 2008-01-24 TFBS::PatternGen(3pm)
All times are GMT -4. The time now is 01:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy