Help With Shell Scripting

Hi

I have a file which has sequence of text as

AAA
BBB
AAA
CCC
DDD
AAA
BBB
EEE
FFF
AAA
CCC
ZZZ
HHH

Now If i want to filer say there patterns {read patterrns in line say "AAA 1H DUT ZZZZ" (i would like to grep from AAA etc )}

"AAA", "BBB" and "CCC"

and want them to appear in sequence as in original file in filtered file

AAA
BBB
AAA
CCC
AAA
BBB
.
.
.

This is kind of urgent Please help , I am using Linux 32 bit platform

Thanks
Niksy

Please show what the original file looks like. You show the first file, but your description leads one to think each line contains more than just those first few characters.
Also, show what you want the output to be.

Hello Joyeg

Ok, it is a log file

which has description like

Host T DPH : 1 Some text
AAA
AAAA
BBBB
AAAA
Host T DPP : 1 Some text
AAA
BBB
ZZZZ
Host R ACK : 1 Some text
AAAA
AAA
AAA
Host T DPH : 2 Some text
AAA
AAAA
BBBB
AAAA
Host T DPP : 2 Some text
AAA
BBB
ZZZZ
Host T DPH : 3 Some text
AAA
AAAA
BBBB
AAAA
Host T DPP : 3 Some text
AAA
BBB
ZZZZ
Host R ACK : 2 Some text
AAAA
AAA
AAA
Host R ACK : 3 Some text
AAAA
AAA
AAA

what i mean is that there are lines which have phrases like i have mentioned and this sequencing of lines is repeated in side original file.

I need to filter lines with these phrases {Host *} from original file as it is so that in output file i have my desired sequence as

Host T DPH : 1 Some Text
Host T DPP : 1 Some Text
Host R ACK : 1 Some Text
Host T DPH : 2 Some Text
Host T DPP : 2 Some Text
Host T DPH : 3 Some Text
Host T DPP : 3 Some Text
Host R ACK : 2 Some text
Host R ACK : 3 Some text

and so on

Thanks
Niksy

I am also not sure I understand what you want, but I'll give it a shot anyways:

$ echo "AAA EEE DUT ZZZ" | tr ' ' '\n' | awk 'FNR==NR{pat[$1];next}($1 in pat)' - testfile
AAA
AAA
AAA
EEE
AAA
ZZZ

This will only match the first field of input file against patterns.

Please bear in mind, that the more specific you are, the better are your chances to get help with your problem.

//=======================================
After reading your real input, i have feeling all you need is :

grep Host input