1 b grep l echo t files having tab character display 1 c grep match strings

1 b grep l echo t files having tab character display

This preview shows page 1 - 2 out of 2 pages.

[1] b) grep -l "`echo $'\t'`" * files having tab character (display) [1] c) grep "^\*" match strings from user input starts with *. [1] d) grep "$SHELL$" /etc/passwd | cut -d: -f1 all the users with shell as the current user (display). ***** q3 [18] Explain whether the following commands are equivalent or not. [2] a) grep "^[^[:lower:]]" ; grep -v "^[[:lower:]]" ans - no [2] b) grep "[0-9]*" ; grep "[0-9*]" ans - no [2] c) grep "[0-9]*" ; grep "[0-9][0-9]*" ans - no [2] d) grep "[0-9]*" ; grep "[a-z]*" ans - no [2] e) grep "[0-9]+" ; grep "[0-9][0-9]*" ans - yes [2] f) grep "^[^^]" ; grep "^^^" ans - no
Image of page 1
[2] g) egrep "(a+b)*b(a+b)*b+$" ; egrep "(a+b)*ba*b(a+b)*$" ans - no [2] h) egrep "(a+b)*b(a+b)*b*$" ; egrep "(a+b)*ba*b(a+b)*$" ans - no [2] i) egrep -x "(a|b)*b(a|b)*ba*" ; egrep -x "a*ba*b(a|b)*" ans - yes ***** q4 [16+2] Use sed to: [2] a) Change all occurrences of <b> and </b> to <strong> and </strong>, respectively [2] b) Delete all leading and trailing spaces on all lines sed -e 's/[[:space:]|[:blank:]]//g' foo [2] c) Only on lines that contain an "a", replace all "o" or "O" with "X" sed -e '/a/s/[oO]/X/g' foo [2] d) On any line, remove the occurrences of "[ED:xxx]" (where xxx is any string of any length not containing "]") without changing the rest of the line. sed "s/\[ED:[^]]*\]//g" [2] e) Replace occurrences of "true" with "false" and vice versa, assuming that the file contains no numerals [2] f) Delete all single line comments. That is "//" and everything that comes after it. ie: "foo // bar" -> "foo " 's/\/\/.*//g' foo [2] g) replace all occurances of "good" with "better" and "better" with "best".
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

  • Fall '16
  • Marketing, Unix SUS2008 utilities, Grep, line number

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes