Thursday, February 16, 2017

Grep and Regex

My Linux Learning Path

Do Linux to learn Linux. Use VIM and create a file named Id.txt with the following (CC, DNI, LIC; are Id denominations):

Id Name
Mauricio CC 71.989.867
Nury CC 98.001.023
Jhon LIC 123.456.874
Mike DNI 53.721.321-X
Alvaro DNI 75.342.123-S
Jose LIC 453.750.884

Now let´s play:
  1. Find Persons with: CC document Id.
  2. Find Persons with: DNI document Id.
  3. Find Persons with: LIC document Id.
  4. Find Persons with: CC, DNI document Id.
  5. Find Persons with: CC, LIC document Id.
  6. Find Persons with: LIC, DNI document Id.
  7. Define a regex pattern for DNI and use it with grep to find all DNI´s.
  8. Define a regex pattern for LIC and use it with grep to find all LIC´s.
  9. Define a regex pattern for CC and use it with grep to find all CC´s.
  10. Another way to identify DNI Id is to find lines that end with a letter. Use regex and grep for this purpose.
  11. Find names with 4 and 5 letters.
  12. Find if any Id repeat a number 2 times.

No comments:

Post a Comment