awk command help

From: Vish grover (vishal_stud_at_yahoo.com)
Date: 10/27/04


Date: 27 Oct 2004 12:59:42 -0700

Hi ,

I wanted to write a awk/sed command to (literally)swap two paramaters
of a functions .
So for eg :
func_foo(param1, param2 , param3 , param4, param5);
should be func_foo(param1, param2, param4, param3 , param5);

Here is my simple awk command file "mycmnd.awk":

BEGIN { RS=";" ; FS ="," }
        /func_foo\(/{
        print $1 "," $2 "," $4 "," $3 "," $5 ";" }
        
my invocation was
awk -f mycmnd.awk $filename > output.txt

The only problem I have is that only my function with swapped params
shows up. How can I get the contents of the whole .c file in my output
with the appropriate changes.

Thanks in advance,

Regards,
V



Relevant Pages

  • Re: Finding pattern more than once per record
    ... > We're doing variable data printing - where a customer supplies us with an image ... > they don't reference an image from the database until it's in the library, ... > I've been trying to come up with an awk solution to extract image names from the ... > better way to specify the match pattern for the first part of the filename? ...
    (comp.lang.awk)
  • Re: construct the filename to process??
    ... the third field has a date "20060905" ... Ed Morton kindly showme this ... but i guess this is when you had passed the second filename as ... 1.construct a unique file to process, maybe using cat inside awk.. ...
    (comp.lang.awk)
  • Re: working with multiple input files
    ... I think you've missed the way awk does processing. ... That's how you should write the script to process these files ... currfile = FILENAME ... For the OP - "getline" has a ton of caveats and must not be used unless you're totally familiar with all of them and have one of those VERY rare sitations where getline is the right solution. ...
    (comp.lang.awk)
  • Re: When to use close(FILENAME) ?
    ... and opened/closed by awk. ... A typical situation where that can ... happen is if the filename depends on some key ... In other applications where you have a lot of different 'some_key's ...
    (comp.lang.awk)
  • Re: awk is not handling my filenames with spaces in.
    ... > The following bit of code is supposed to find the data files in a ... > The find is finding the correct files, but when these are passed to awk ... So if the file is called 'foo bar' it gets indexed as only foo. ... then use the entire filename instead ...
    (comp.unix.shell)