I want to display users in my linux whose name ends on number
I tried grep ‘[0-9]’ /etc/passwd but it displays all lines containing numbers
>Solution :
You can use awk for this:
awk -F: '{ print $1}' /etc/passwd | grep '[0-9]$'
Alternatively you could also use cut
cut -d: -f1 /etc/passwd | grep '[0-9]$'
Both work essentially the same way. They split a line within the file using : as a delimiter and then print the first result of that split.
The grep command uses the end of string anchor $ to match the end of the user name.