Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

(a) SED Given a file, replace all the sequences of 4 or more digits with the word "cat".

(b) GREP Given a file, display all the lines starting with the word "cat" and ending with the word "mouse".

share|improve this question
9  
You should at least make an effort to do your homework before asking for help. –  jordanm Apr 8 '13 at 16:02
3  
Please ask one question per question. –  N.N. Apr 8 '13 at 16:13
    
Or at least try to make it look a little less like a homework assignment. –  Shadur Apr 8 '13 at 18:16
add comment

closed as too localized by derobert, Ulrich Dangel, Renan, vonbrand, jasonwryan Apr 8 '13 at 18:08

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

a) sed 's/[0-9]\{4,\}/cat/g'

s=substitute, [0-9]=range of numbers, \{4,\}=4 or more occurrences, g=global - i.e. for all matching occurrences, not just the first match on each line

b) grep '^cat.*mouse$'

^=beginning of the line, .=any character, *=0,1 or more occurrences of previous (here .), $=the end of the line

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.