Hi rincewind,
I am a Linux newbie, but for that more attentive to the needs of a "collegue" (as far as Linux is concerned... you are a C++ programmer, and only for that an "expert")
I thought to know well shell programming and for that I wanted to try something more like a programming language (Python). I've read a few books in C++ programming, but I don't like it and its OOP...
Back to your problem... It has interested me mainly for the fact of the recursion on subdirs (hidden or not).
When I red the first time your post you had till that time received no answer. Now a Senior Member (jschiwal) has given his expert's opinion (to say the truth I've understood almost nothing - I hope not to have a one more enemy...).
Perhaps you has already solved on the ground of jschiwal's indications your problem...
For what it can useful... (at least for me, it has been very interesting).
The problem is the search also on the subdirs.
I use a for cycle which in Bash programming is different from C/C++ "for";
the sintax is:
Code:
for arg in[list]
do
command(s)...
done
If your cpp files were in a single dir, the syntax should be:
Code:
for cpp_files in /dir_containing_cpp_files/*.cpp
do
command(s)... # text replacing instructions
done
You need to build a <list> for taking into account also subdirs.
My solution is:
Code:
n=0 #counter and list initialization
LIST_CUMUL=""
# pay attention to the back-quotes!
# if for ex. your dir is CPP (with subdirs sources, .include etc...)
# the for would be:
# for cpp_files in `find /CPP/*.cpp`
for cpp_files in `find /dir_containing_cpp_files/*.cpp`
do
LIST_CUMUL="$LIST_CUMUL$cpp_files "
done
Pay attention to the blank in the generated list! The elements of the list use blanks or LFs as separators.
For this reason in your filenames blank is forbidden...
It must be substituted with "_" by means of very simple shell commands:
Code:
find /dir_containing_cpp_files/*.cpp | grep " " # search for blanks
mv "filename with blanks" filename_without_blanks
With the new list ($LIST_CUMUL) you can then run another for cycle:
Code:
for i in $LIST_CUMUL
command(s)... # text replacing instructions
done
If you print $LIST_CUMUL by means of:
you will see that all your cpp files are there...