In bash 4.0 you can just use the newly supported **
operator.
You have to enable it first on some with :
shopt -s globstar
You can then do
echo **
which recursively echos all files that are descendant of the current dir.
Beware it does tend to bail out on overly complicated dirs sometimes, so use the ** at the lowest recucurring point.
echo **/
Coincidentally, emits recursively all directory names, and only directory names. ( Excluding the current dir )
echo ./**/
Includes the current dir. ( Incidentally, it also skips hidden directories )
This should thuswise be suited for creating a path string:
echo ./**/ | sed 's/\s\s*/:/g'
And if you don't want relative paths,
echo $PWD/**/ | sed 's/\s\s*/:/g'
Ack
From your comment on one of the other posts it sounds like you're wanting behaviour much like 'Ack' provides. If you were intending to use a find + grep combination, this tool is generally much more efficient and easier to use for this task.
Example:
# search for 'mystring' in all c++ files recursively ( excluding SCM dirs and backup files )
ack "mystring" --type=cpp
# finds all text files not in an SCM dir ( recursively) and not a backup using type heuristics.
ack -f --type=text