-3

I'm playing with the Linux terminal and I have to do a exercise which states that I have to find inside a file for any line that contains at least an a, b and c, it doesn't matter it the lane has 2 a, 1 b and 1c or 1 a, 55 b, and 3 c. Like I said it needs to have at lest one a, one b and one c.

Example:

Input:

aaaaaaaaaaaa
bbbbbbbbbbbb
cccccccccccc
abcabcabcabc
hhahhhbhhhhc
aabbccpppppp
thisisrandom
nononononono
aandbandcnoo
dddddddddddd

Output(valid):

abcabcabcabc
hhahhhbhhhhc
aabbccpppppp
aandbandcnoo

All the content are inside a .txt file.

Edit: It needs to be done with a regular expression and metacharacters

1 Answers1

1

You need to learn regexes, [abc] means at least one a, one b, one c.

grep [abc] FILE.txt

You can learn regexes with grep here

Darek
  • 541