Victor
Victor

Reputation: 1345

bash find command not giving the output i would expect

Im trying to get the hang of the command find but im kind of confused as to why i get this kind of output from this code can anyone explain? Output:

file1
file2
file3
etc...
good morning

What i want is

file1
good morning
file2
good morning
file3
good morning

etc....

for line in `find $1 -type f`
do  
    echo $line
    echo hello good morning                     
done

Thanks in advance

Upvotes: 1

Views: 287

Answers (2)

clt60
clt60

Reputation: 63974

Or

find $1 -type f -print -exec echo good morning \;

or even shorter if you have gnu-find

find $1 -type f -printf "%p\ngoog morning\n"

Upvotes: 1

frankc
frankc

Reputation: 11483

You code should work. This is another way to try it:
find . -type f -exec echo -e {}"\n" good morning \;

Upvotes: 1

Related Questions