0

I am running a grep command on each file in a directory. I want the outputs to be appended into the same file. Is this possible?

Here is what I am using unsuccessfully:

for f in /directory/*.txt
do
grep -Eo "[0-9]+\.[0-9]+" $f >> one_output_file.txt
done

I am grepping out a number from each file and I want the numbers to be listed together in ONE output file. Possible?

Thanks!

1 Answer 1

1

Why not drop the for loop and do

grep -Eoh "[0-9]+\.[0-9]+" /directory/*.txt > one_output_file.txt
Sign up to request clarification or add additional context in comments.

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.