A schoolboyish stuff

Hi ,
This is a pretty simple sed command i found when i was checking out one of the codes of my colleague .

sed -e 's/\[A-Za-z]*.*\) \(\ <1[a-z]*e\ >\) \([a-zA-Z]*.*\)/\2/' 

When i tried this on a few text files it was displaying the entire line. If this was to display entire line why sweat out on a sed . Does this has more than just that.

Can someone clarify ?

Well theres one more on the same lines

sed -e ' { / </ { N; /\n.*. { s/\ <.\n.* >/ < >/ } } }'

Hi, the first sed is missing a forward parenthesis, so it will not work. Anyway a sed command with those options only changes a line when it makes a match. Otherwise it will just display the unchanged line. More grep-like behavior requires the -n option. E.g:

sed -n 's/\([A-Za-z]*.*\) \(\ <1[a-z]*e\ >\) \([a-zA-Z]*.*\)/\2/p' 

will most likely not display anything since no match was found. If you feed it e.g.:

echo "blabla  <1yadeyade > blabla  " | sed ...

then it will return

 <1yadeyade >

The second expression is missing a forward slash. If you feed it

 echo " <
blabla >"|sed -e ' { / </ { N; /\n.*./ { s/\ <.\n.* >/ < >/ } } }'

it will return:

 < >

Why does
echo "blal <1yassads > <1yassa> bla " | sed -n 's/\([A-Za-z]*.*\) \(\ <1[a-z]e\ >\) \([a-zA-Z]*.\)/\2/p'

not return anything for the first command

Because <1yassa> is not matched by the second [a-zA-Z]*.*