[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use comm command with regular expression
From: |
Bob Proulx |
Subject: |
Re: use comm command with regular expression |
Date: |
Fri, 15 Jun 2012 14:02:07 -0600 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
e-letter wrote:
> File 1 contains data:
> /some/text/abcd.xyz
>
> File 2:
> abcd.xyz
>
> The manual does not seem to indicate that regular expressions can be
> used with 'comm'.
They can't be. It doesn't make sense for comm. Perhaps you should be
using 'grep' or 'sed'?
> The task is to be able to compare file1 to file2 using a regular
> expression as a criterion for comparison, such as:
>
> *cd.xyz
>
> Then create a new file 'file3' that contains only those lines that
> satisfy the regular expression, but must contain the same format style
> as in file1.
Sounds like a homework assignment.
> Any help please?
$ grep -F cd.xyz file1 > file3
Or perhaps:
$ grep -f file2 file1 > file3
But note that "*cd.xyz" doesn't make sense as a regular expression.
It looks like a file glob match instead. Watch that string being used
for a regular expression carefully. Perhaps "cd\.xyz" instead.
Good luck on working through your homework! :-)
Bob