Article 53TZF egrep in an archieve

egrep in an archieve

by
ektoren
from LinuxQuestions.org on (#53TZF)
I tried to solve an exercise I find in a website but I am wrong.. in every answer..I have wrote the commands using the egrep but I am wrong.What I am doing wrong ?
In every question you must read from the archieve /etc/catalog. In the surname and name it can be any character except of space or :

Iris Ksimis,:3553:asop:asop@yahoocom,asop@hotmail.com:22494012
Smenos Fomis:1242:smenos:smenos@hotmail.comm:391310495,5301-203
Aminiou Emos:2356:aminiou:aminiou@yahoo.com:3012349104852
So as you can see there is name-surname,code,username,emails,phones. The fields are split by ":". The emails or phones(if existed more than 1) are split by ","

1)Give the command that counts users whose names ends with y(Y). what I did and it is wrong .

egrep --color -wc -i "y$" /etc/catalog
I use -wc to count -i so that it doesn't play role the y or Y. y$ end of the line.

it's wrong and I have no idea why.

2)Give the command that counts the uses whose (at least ) one of the phones starts with 1

egrep --color -wc "^([^:]*:){3}:1.*$" /etc/catalog
^([^:]*:){3} I did that so those : for 3 times will not be appeared.

3)Give the command that counts the users whose they don't have the digit 1 in their phones.

egrep --color -wc "^([^:]*:){3}:[^1]" /etc/catalog
4)Give the command that appears the users (all the line ) whose usernames are not have those characters l until m(L until M)and they have email in hotmail.

egrep --color -i ' [lm]' /etc/catalog
5)Give the command that counts the users whose usernames ends with u(U) and they have email yahoo.

egrep --color -i "^([^:]*:){2}:u$:.*yahoo.com.*" /etc/catalog
6)Give the commands that appears all the users (all the line ) whose username(whole username) are similar with the whole surname I have no idea how to do that..latest?d=yIl2AUoC8zA latest?i=QQcp78Pvkig:S5hLQQOPElE:F7zBnMy latest?i=QQcp78Pvkig:S5hLQQOPElE:V_sGLiP latest?d=qj6IDK7rITs latest?i=QQcp78Pvkig:S5hLQQOPElE:gIN9vFwQQcp78Pvkig
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments