1

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

3
  • Thanks for cleaning that up =p Commented Jun 3, 2011 at 17:53
  • 3
    As it is, this code should work. Are you running it from a file? Commented Jun 3, 2011 at 18:08
  • 2
    neither your actual output nor your expected output matches your code. Please post the actual code. Commented Jun 3, 2011 at 18:12

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.