Fetching a line matching a pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fetching a line matching a pattern
# 8  
Old 07-01-2015
On first sight, I can't see a match between lines in "other file" and "big file". How do you expect anyone to compose some code when it can't be seriously tested against meaningful samples?
# 9  
Old 07-01-2015
Sorry, I gave that for sample. The list is actually huge so i just took some samples.

Please use the below jobs for testing the jobs from schedules.

Code:
A01G3GBOAPP1A#J01AQMSPSR2PWEB
A01G3GBOAPP1A#J01AQMSPEMAILIN
A01G3GWPAPP1A#J01G3GPND2R007

# 10  
Old 07-01-2015
This is my IMMEDIATE result running my unmodified proposal against your samples:
Code:
A01G3GBOAPP1A#J01AQMSPSR2PWEB A01G3GBOAPP1A#J01AQMSPBATCH01
A01G3GBOAPP1A#J01AQMSPEMAILIN A01G3GBOAPP1A#J01AQMSPBATCH02
A01G3GWPAPP1A#J01G3GPND2R007 not in file1

So - where's the problem?
# 11  
Old 07-06-2015
That is working fine. the issue was with my file1 which is not in the correct format. When i print $2, it leaves the first 3 characters and fetches the remaining lines.

that was the reason i for not available for all the records in file1. Extracted the file again and got this done.

Thanks much for the help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing spaces from line matching a pattern

Hi, I want to remove the spaces from all the lines matching a particular pattern from my file. For instance in file abc.txt I have following data. Header,This is the header 111,this is 1st record 222, this is 2nd record 333, this is 3rd record Footer,3 records found Footer,111222333 ... (5 Replies)
Discussion started by: decci_7
5 Replies

2. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

3. Shell Programming and Scripting

matching pattern to end of line

I have the following code and want to get only the comments. Ideally I would like to replace the characters to the left of the first '!' in the line with blanks. real, dimension(:), allocatable :: ft ! stores a single trace real, dimension(:), allocatable :: tr ! stores a single... (8 Replies)
Discussion started by: kristinu
8 Replies

4. Shell Programming and Scripting

Fetching string after matching pattern from last

I have a file a file having entries are like @ram@sham@sita @krishan@kumar @deep@kumar@hello@sham in this file all line are having different no of pattern-@. need to fetch the substring after the last pattern. like sita kumar sham thanks in advance (3 Replies)
Discussion started by: saluja.deepak
3 Replies

5. Shell Programming and Scripting

How to use sed to modify a line above or below matching pattern?

I couldn't figure out how to use sed or any other shell to do the following. Can anyone help? Thanks. If seeing a string (e.g., TODAY) in the line, replace a string in the line above (e.g, replace "Raining" with "Sunny") and replace a string in the line below (e.g., replace "Reading" with... (7 Replies)
Discussion started by: sprinner
7 Replies

6. Shell Programming and Scripting

Shell Scripting:Fetching content from each line with respect to pattern.

one.txt ONS.820.log:V 20Oct2010:GP ^ ^ ONS.123.log:V 21Oct2010:GP ^ ^ ONS.820.log:V 30Oct2010:GP ^ ^ want to make new file from existing one with addition. 20Oct2010 User KV001 has name tk003 with buffer- 338-1 21Oct2010 User KV003 has name tk002 with buffer- 338-2 30Oct2010 User KV002... (5 Replies)
Discussion started by: saluja.deepak
5 Replies

7. Shell Programming and Scripting

Extracting a string matching a pattern from a line

Hi All, I am pretty new to pattern matching and extraction using shell scripting. Could anyone please help me in extracting the word matching a pattern from a line in bash. Input Sample (can vary between any of the 3 samples below): 1) Adaptec SCSI RAID 5445 2) Adaptec SCSI 5445S RAID 3)... (8 Replies)
Discussion started by: jharish
8 Replies

8. Shell Programming and Scripting

Fetching just the matching pattern

Hi Everybody, I would like you to help me with the following problem. Given is a path to a file like this: /root/DIR/subdir/file.dat Having this path I would like to grep/sed or whatever the directory string that matches the following pattern ''. I just need the matching directory... (5 Replies)
Discussion started by: hhoosscchhii
5 Replies

9. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

10. UNIX for Dummies Questions & Answers

exclude columns with a matching line pattern

Hi , I have 5 columns total and am wanting to search lines in columns 3-5 and basically grep -v patterns that match 'BBB_0123' 'BVG_0895' 'BSD_0987' Does anyone know how to do this? I tried combining grep -v with grep -e but, it didn't work. Thanks! (5 Replies)
Discussion started by: greptastic
5 Replies
Login or Register to Ask a Question