[Lvlug] Re: Need some sed/awk magic
Faber Fedor
faber at linuxnj.com
Wed Aug 24 00:09:08 EDT 2005
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?
(warning: untested code)
#!/bin/bash
for i in $(ls /devices/*): do
/usr/bin/perl -i.BAK -p -e 's/#include <(..*)>/#include <uc($1)>/' $i
done
exit
The idea is this:
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.
You'll prolly have to play with the perl search term (the part after s/)
to get it just right.
--
Regards,
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701
http://www.linuxnj.com
More information about the Lvlug
mailing list