sed or awk, how can I do this ?

sed or awk, how can I do this ?

Post by Ralph J. Verril » Sat, 20 Apr 1996 04:00:00

In a Unix script, I'd like to do some file copying.  However, I want to
make the name of the file I am copying  dependent on the input arguments
to the script.  I believe I can do this with either sed or awk, however, I
am not sure how to do it with either.  Can someone please provide an
example?  Thanks.

For example, if I have a file named MRN-001.dat, I'd like to call a script
named copy_file as follows:

copy_file   MRN-001.dat  'MRN'  'RNG'  'MOL'

copy_file would copy the file MRN-001.dat to two files, one named
RNG-001.dat, the other named MOL-001.dat.  The number of files I am
copying will be the number of arguments I provide after the string I would
like to chaange, in this case, 'MRN'.

Thanks again.


Ralph J. Verrilli

Composite Design Technologies
47 River St, Suite 210
Wellesley, MA 02181


1. grep/sed/awk/vi for dos


   Is there an FTP site where I can get sed/awk/grep/vi/etc...
useful unix programs for DOS.

Thanks in advance.


| Any opinions are my own.        | Weinberg's Principle:            |
| Any resemblance to anyone elses | An expert is a person who avoids |
| (living, dead or asleep) is a   | the small errors while sweeping  |
| coincidence.                    | on to the grand fallacy.         |


2. Dual booting

3. sed/awk - generating Makefiles (Re: awk processing of Makefile macros)

4. modify user area from process?

5. sed sed sed

6. won't install

7. . 2 sed FAQs, sed exes, sed cetras; URLs

8. file contains no data, cgi-script


10. (sed 1q ; sed 2q) : no output from 2nd 'sed'

11. Help with awk/sed word extracting

12. sed/awk : need just the first column in a multi-column file

13. Sed or awk ?