If you have this text file containing:
█▓▒░bondhan@optimus-prime█▓▒░ Wed Dec 22 14:00:23/media/BONDHAN_4GB/workspace/grep_exercise/ cat grep_exercise.sh1. Print all lines containing the string San.2. Print all lines where the person’s first name starts with J.3. Print all lines ending in 700.4. Print all lines that don’t contain 834.5. Print all lines where birthdays are in December.6. Print all lines where the phone number is in the 408 area code.7. Print all lines containing an uppercase letter, followed by four lowercase letters, a comma, a space, and one uppercase letter.8. Print lines where the last name begins with K or k.9. Print lines preceded by a line number where the salary is a six-figure number.10. Print lines containing Lincoln or lincoln (remember that grep is insensitive to case).
If you want to append word echo “ in front of each line and add the “ at the end of each line, then this is the command:
sed -e ‘s/^[ \t]*/echo \”/g’ -e ‘s/\.$/\”/g’ grep_exercise.sh
The command above will search for a blank line or tab at the beginning of each line then replace with echo “ and then after -e flag the it will find at the end of each line (.$) and replace with ” (\”).
The result: Continue reading
