Re: in-place editing in awk



On Jun 24, 9:42 am, Dave B <da...@xxxxxxxxxxxx> wrote:
Jeenu wrote:

I'm trying to achieve some thing like this: I've a auto-generated C
header file containing function prototypes. But their respective
definitions are different (only in return type) from that of the
prototype -- something that the compiler would complain about. So I
wanted to modify the header file -- i.e. to correct the return types
-- by finding the definition from .c files.

I've been doing this with the help of grep, sed and a bit of
awk. But as I see it, this involves reading from disk all
the time when ever I've to find a definition. What I hope to
achieve with awk, is that, I read all the required file to a
buffer, and I do an in-memory search- and-replace, and later
write it back to disk, so that I don't need to read the disk
every time I need to find something -- something like the -i
option in sed.

Then do that with sed. What's wrong with

sed -i.bak '...sed code...' file1 file2 file3 .. fileN

This reads and modifies all the files in place, creating .bak
files in case something goes wrong.

Not with standard sed. The only options sed understands are -e,
-f and -n.

--
James Kanze (GABI Software) email:james.kanze@xxxxxxxxx
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
.



Relevant Pages

  • Re: in-place editing in awk
    ... header file containing function prototypes. ... I've been doing this with the help of grep, sed and a bit of awk. ... and-replace, and later write it back to disk, so that I don't need to ...
    (comp.unix.shell)
  • Re: in-place editing in awk
    ... but as I said, this involves a lot of disk ... I wouldn't bother attempting that in sed, but in awk and assuming your ... Identifying the function definition lines in the C files will be the hard part - ... Why are you botheroing with the original header file at all when you could just ...
    (comp.unix.shell)
  • in-place editing in awk
    ... header file containing function prototypes. ... I've been doing this with the help of grep, sed and a bit of awk. ... and-replace, and later write it back to disk, so that I don't need to ...
    (comp.unix.shell)
  • Re: why still use C?
    ... >> of comments, preprocessor directives, typedefs, and function prototypes. ... > any use of them in a header file context dangerous. ...
    (comp.lang.c)
  • Re: Function prototypes
    ... Hi, I'm currently taking a data structures course in C, and my teacher ... also said that no professional programmers use function prototypes. ... prototypes in the header file, my compiler would assume the function ...
    (comp.lang.c)