On Mon, Sep 01, 2008 at 05:14:10PM -0400, Vitaliy wrote: > Suppose we have two files: > > file1.c: > function *TOKEN* { Nop(); } > function *TOKEN* { Nop(); } > ... > > file2.txt > MyFunction() > MySecondFunction() > .... > > ...and we want to replace *TOKEN* in file1.c with actual function names. How > do we accomplish the above, with the least amount of work? Are there editors > out there, that can do this? Probably not. I just wrote a bash script that uses sed to pull this off: #!/bin/bash # file2.txt is file subtokens in this script. # file1.c is called token.c in this script. for i in $(seq $(wc -l subtokens | cut -d' ' -f1)) ; do ln=$(grep -n '*TOKEN*' token.c | head -1 | cut -d: -f1) target=$(tail -n +$i subtokens | head -1) echo $i:$ln:$target sed "${ln}s/\\*TOKEN\\*/$target/" token.c > newtoken.c mv newtoken.c token.c done > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist