Score:0

how do I filter using grep with logins ending with a specified number

eg flag

grep how can I find all the user logins that end with 88 and 89 ? I can get logins ending with a number if I do grep "[0-9]" filename

Score:1
in flag
CPH

If you only want to show those ending in 88 and 89, you can use grep -e "88$" -e "89$"

The '$' notates the end of the line.

Score:1
cn flag

You already know how to use character classes: [0-9] is a character class that means "all the digits from 0 until 9". You can use more specific sets as well. For instance, [89] means "either 8 or 9". Finally, in regular expressions, $ means "the end of the line". So, putting all this together, you can do:

grep '8[89]$' file

That will print any lines in the file file that end with an 8 followed by either another 8 or a 9, in other words, lines ending with 88 or 89.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.