TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:10162] awk syntax help needed



On Tue, Nov 16, 1999 at 02:11:15PM -0800, Carl Wilhelm Soderstrom wrote:
>         I need to know how to use the system() function in awk.
> I need to take a list of filenames (with no extension), and move files with
> those names (but varying extensions, which i will specify in the script),
> from one directory to another. the manuals are remarkably unhelpful in this
> case...
> 
> here's the line in question:
> system(cp /from/this/dir/$1.ext /home/here/ )
> 
> and here's the error it gives:
> awk: copy.awk:7: system(cp /from/this/dir/$1.ext /home/here/ )
> awk: copy.awk:7:                                            ^ parse error
> awk: copy.awk:7: fatal: system() cannot have 0 arguments                
> 
> why does it give me a parse error on that command? I've tried just the bare
> command on the command line, and it works fine.
> 
> Carl Soderstrom
> 
> p.s. I know that Perl will do the job too.. but I know neither awk nor perl,
> and awk seemed like a more straighforward solution to learn at the moment. :)

	Well, if it were perl, I'd know the problem instantly.  :-)

	As it is, I think you're missing "'s around the argument to the
system command.  I'm guessing that your command should look like this:

system("cp /from/this/dir/" + $1 + ".ext /home/here/")

Have fun (if at all possible),
-- 
Its name is Public Opinion.  It is held in reverence. It settles everything.
Some think it is the voice of God.  Loyalty to petrified opinion never yet
broke a chain or freed a human soul.     ---Mark Twain
-- Eric Hopper (hopper@omnifarious.mn.org
                http://ehopper-host105.dsl.visi.com/~hopper) --

PGP signature