[Lvlug] Re: Need some sed/awk magic
Ricardo SIGNES
rjbs-lvlug at lists.manxome.org
Wed Aug 24 08:39:51 EDT 2005
* Faber Fedor <faber at linuxnj.com> [2005-08-24T00:09:08]
> On 23/08/05 21:29 -0400, Mark wrote:
> > So what I need to do is for each filename (133 files) in 'devices'
> > change every #include <FILENAME> to #include <filename> in every
> > source file in the examples directory.
> Where's Ricardo when you need him? :-)
;)
> How about a little shell + Perl?
You were close; here is some more likely to work, but still untested,
code:
perl -pi.BAK -e 's/\A#include <([^>]+)/"#include <".lc($1)/e' devices/*
> loop through each file in the /devices/ directory placing the name in
> variable i. Execute a perl "edit in place" command on each file $i.
> Search for "#include <regular expression>" and replace it with "#include
> <upper case of the previously found regular expression>". Make a backup
> copy of the file using the .BAK extension as well.
Look isn't needed; feed the list of files to perl as arguments, assuming
there aren't too many. To use a function on the rhs of s/// you must
use the /e modifier, which means you should also enquote the non-code
part of it. Also, Mark wanted to lc, not uc. ;)
--
rjbs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.thelinuxlink.net/pipermail/lvlug/attachments/20050824/1d4f1cf4/attachment-0001.bin
More information about the Lvlug
mailing list