[comp.unix.questions] Wildcard expressions from the command line.

brobes@auto-trol.UUCP (Brooke Besser) (01/05/90)

In the "ed" regular expressions, we are able to use a syntax to remember a
wildcard string as follows:

      /(.*\)

This syntax will remember the wildcard expression, and enable it to be used
with a "\#", where # is the position of the wildcard string in the regular
expression.

The problem is that this syntax cannot be used on the command line. This is
needed to be able to perform wildcard file manipulation. For example, if I
want to copy all files with a ".ftn" extension to a ".for" extension, how can
I copy these without writing a special shell script? If I could use the "ed"
regular wildcard expression, it would look like this:

     cp \(*\).ftn \1.for

Is there any way to do this from the command line?

jik@athena.mit.edu (Jonathan I. Kamens) (01/05/90)

In article <569@auto-trol.UUCP>, brobes@auto-trol.UUCP (Brooke Besser) writes:
> The problem is that this syntax cannot be used on the command line. This is
> needed to be able to perform wildcard file manipulation. For example, if I
> want to copy all files with a ".ftn" extension to a ".for" extension, how can
> I copy these without writing a special shell script? If I could use the "ed"
> regular wildcard expression, it would look like this:
> 
>      cp \(*\).ftn \1.for
> 
> Is there any way to do this from the command line?

  The simple answer is, "No."

  This is one of the questions answered in the monthly
comp.unix.questions Frequently Asked Questions posting.  The most recent
posting of that message was January 3, which means that if your site
hasn't gotten it yet you should be getting it very soon.

  It is question number 9 in that posting.

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik@Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710

ken@cs.rochester.edu (Ken Yap) (01/05/90)

|The problem is that this syntax cannot be used on the command line. This is
|needed to be able to perform wildcard file manipulation. For example, if I
|want to copy all files with a ".ftn" extension to a ".for" extension, how can
|I copy these without writing a special shell script? If I could use the "ed"
|regular wildcard expression, it would look like this:
|
|     cp \(*\).ftn \1.for
|
|Is there any way to do this from the command line?

Ah, my favourite example of using sh in a pipeline:

	ls *.ftn | sed 's/\(.*\).ftn/cp & \1.for/' | sh