grep for a word

Hi,

I have a file which looks sometthing like this.

<MS20120215-12.59.13.658 type="error"><log>STI_000000550_Job0_Job0: Error when retrieving UAProf. Key: "SAMSUNG-GT-E2222/E2222DDKE5" not found in repository.</log></MS20120215-12.59.13.658>

I want to write a script which would only grep for a word and not lines which has ""SAMSUNG-GT-E2222/E2222DDKE5". I want to get the list of all the devices with name samsun-XXX-XXX"

-Siddhesh

maybe something like this:

grep -e '\"SAMSUNG-[A-Za-z0-9/-]\+\"' yourfilename

searches for all between "" starting with "SAMSUNG"..

Thanks,

It works, Here is the output..

<MS20120215-15.10.52.857 type="error"><log>STI_000000150_Job0_Job0: Error when retrieving UAProf. Key: "SAMSUNG-GT-C3212i/C3212IDDKC1" not found in repository.</log></MS20120215-15.10.52.857>
<MS20120215-15.11.07.228 type="error"><log>STI_000000156_Job0_Job0: Error when retrieving UAProf. Key: "SAMSUNG-GT-C3303i/C3303iDDKB2" not found in repository.</log></MS20120215-15.11.07.228>

I want only list of "SAMSUNG-GT-xxxc/xxxx"

Please help.

-Siddhesh

awk -F\" '/SAMSUNG/ {print $4}' input.txt

Thanks,

again it give me below output.

SAMSUNG-GT-B5310/B5310DDIK5 SHP/VPP/R5 Dolfin/1.5 Nextreaming SMM-MMS/1.2.0 profile/MIDP-2.1 configuration/CLDC-1.1
SAMSUNG-GT-C3303i/C3303iDDKB2
SAMSUNG-GT-C3200/1.0 NetFront/3.5 Profile/MIDP-2.0 Configuration/CLDC-1.1
job1
SAMSUNG-GT-C3200/1.0 NetFront/3.5 Profile/MIDP-2.0 Configuration/CLDC-1.1
job1

i want list of only first word. i.e. SAMSUNG-GT-xxxx/

-Siddhesh

awk '/SAMSUNG/' RS=\" infile
awk '/SAMSUNG/{print $1}' RS=\" infile
grep -o 'SAMSUNG-GT-[^/]*/[^"]*' infile
2 Likes

Hi,

Thanks for the reply.

I need it only for the line which has type=error as mentioned above.

Sorry i did not mention this earlier.

-Siddhesh

Run it through

grep 'type="error"'

first, e.g.

grep 'type="error"' infile | awk '/SAMSUNG/' RS=\"

and so on for all the other solutions in this thread...

grep error your_file | cut -d'"' -f4.....

try this

$ grep "type=\"error\'.*SAMSUNG" infile.txt \
   | sed -e 's/^.*Key" //g' \
   | awk -F\" '{print $1}'