Help w/ matching grep and regular expressions

From: WH (nos.pam_at_email.com)
Date: 03/11/04


Date: Thu, 11 Mar 2004 03:18:25 GMT

I'm doing an assignment for a unix class, but I'm stuck on two questions.

3. Write a command that removes all files that end in a ".log" extension,
and do not contain the string "west". Remove them form your home directory,
and all subdirectories, recursively.

4. Write a command that produces the 'ls -l" output for the current
directory, but only lists files and directories for which the "other"
category (as opposed to "user" and "group" has execution permission.

With number 3, if I ignore the part about west, I would do a

 find . -name *.log | xargs rm

But with the west there, I know I want to grep it, and have grep say
something like "match all lines except those with 'west'" but I can't figure
out how to do it. I scoured the web for an hour, and all I could find for
"except" was the ^carrot, which is useless here.

With number four, since permissions always have ten characters, I'd want to
match anything w/ ten characters, ending in x. I've got no idea how to
match the end of a word, just the end of a line w/ $.



Relevant Pages

  • Re: How to search inside files
    ... > of characters. ... Does anyone know the command so that I may look ... Grep, like Barry said, or if you want to do it while viewing the ... Use regular expressions, not shell wildcards. ...
    (comp.unix.questions)
  • Re: find - exec vs xargs
    ... If I use exec grep it takes way longer ... to complete than xargs grep. ... It is likely that the time of this command is dominated by the ... outputs a list of file names separated by NL characters while NL ...
    (comp.unix.shell)
  • Re: Set App Priority
    ... string and then terminates" ... gives then parameters to use to modify the START command ... below) /F:OFF Disable file and directory name completion characters ... no special characters between the two quote characters, ...
    (microsoft.public.windowsxp.customize)
  • Re: Set App Priority
    ... This would start notepad with high priority. ... Starts a new instance of the Windows XP command interpreter ... /F:OFF Disable file and directory name completion characters ... If all of the following conditions are met, then quote characters ...
    (microsoft.public.windowsxp.customize)
  • Re: DOS Box Keyboard problem
    ... I get 437 from command chcp and cmd chcp. ... When in the cmd box I can type with all characters OK ... The OEMCP value controls to which OEM code page to translate ANSI, ...
    (microsoft.public.windowsxp.configuration_manage)