Fetch Valid String

Hi All,

How to fetch the particular row based on my search command. For example

Source Column

Column A Column B
 
001,56123456
002,57123456
003,123456

Expected Output:

003,123456

To get this output I tried below mentioned function

grep '123456' filename.txt

but I got all three rows. I need to fetch only the particular rows from my source file. Please guide me how can I do that.

Thanks

Suresh

$ awk -F, '$2 == search' search="123456" filename.txt

try also:

sed -n '/\b123456\b/p' infile
#!/usr/bin/env perl
use strict;
use warnings;

while(<>){
	my @sp = split(/,/ , $_);	
	print if $sp[1] == 123456; 
}

Really thanks to everyone for your right time help