echo and grep commands

Hey im new in this...anything will be helpful...

The user will input the word or phrase .... I want to search the user input in file (by lines) but not all then with this line search on another file ( with the specific line) and show to the user.

Example:

file1.txt

a
aa
aaa
aab
aac

file2.txt (corresponding md5 hashes of every text line)

0cc175b9c0f1b6a831c399e269772661
4124bc0a9335c27f086f24ba207a4912
47bce5c74f589f4867dbd57e9ca9f808
e62595ee98b585153dac87ce1ab69c3c
a9ced3dad556814ed46042de696e1849

========
Lets supposed to the user enter (want to crack) this hash: a9ced3dad556814ed46042de696e1849

im using

grep -n -w a9ced3dad556814ed46042de696e1849 file2.txt

but i want the output --> aac

Any ideas :confused:??

Thanks in advance

Try this..

#!/bin/bash
linenum=$( grep -w -n a9ced3dad556814ed46042de696e1849 file2.txt | cut -f1 -d: )
sed -n "$linenum p" file1.txt

--ahamed

YES. It Works!

But Im trying to call this command (sed -n "$linenum p" file1.txt) from a pipeline in C and I doesn't works ... And I think the error is the double quotes can i run the command something different.. sed -n $linenum p file1.txt (but this way doesn't work)

look my var

char sed[1024] = "sed -n "$linenum" p file.txt;  

Thankss in advance.