This is a training task for the grep utility. There is a datebook file with this format:

James Ikeda:834-938-8376:23445 Aster Ave., Allentown, NJ 83745:12/1/38:45000 Jesse Neal:408-233-8971:45 Rose Terrace, San Francisco, CA 92303:2/3/36:25000 Jose Santiago:385-898-8357:38 Fife Way, Abilene, TX 39673:1/5/58:95600 

You need to use the grep utility to display certain lines.

  1. Print all lines containing the Sun string:
    grep 'Sun' datebook
  2. Print all lines where people’s names begin with J: grep '^ J' datebook
  3. Print all lines ending with 700: grep '700 $' datebook
  4. Print all lines that do not contain 834 ???
  5. Print all lines, happy birthday in December: grep '/ 12 /' datebook
  6. Print all lines with phone numbers starting with 408: grep '438-' datebook
  7. Print all lines containing the following sequence of characters: capital letter, four lower case letters, comma, space and one capital letter: grep '[AZ] [az] {4}, [AZ]' datebook
  8. Print all the lines in which the last name starts with K or k: grep '^. [Az] [Kk]' datebook *
  9. Print all lines with their sequence numbers, where the last numeric field of the record consists of six digits ???
  10. Print all lines containing the words Lincoln or lincoln ???

Tell me how you can implement items 4, 9, 10. And how optimally are the others done?

    1 answer 1

    4 grep -v '834' datebook

    9 grep -n '[0-9]\{6\}$' datebook

    10 grep '[Ll]inkoln' datebook

    everything else is normal