-3

I have files in different directories under a parent directory, something like this:

  • Parent Dir
    • Dir 1 - File 1
    • Dir 2 - File 2

I want to have an output file that appends the content of File1 with File2. How do I do it in Bash?

5
  • find /parentDir -type f -print0 | xargs -0 cat > singleFile Commented Mar 7, 2018 at 11:10
  • It goes in an infinite loop @anubhava Commented Mar 7, 2018 at 11:18
  • cat dir1/file1 dir2/file2 > newfile Commented Mar 7, 2018 at 11:27
  • 1
    @anubhava It worked, find home -name "*.orc" -print0 | xargs -0 cat > test.orc Commented Mar 7, 2018 at 11:29
  • @anubhava The reason was that I was saving it in the same directory where it was reading from, so the infinite loop. Commented Mar 7, 2018 at 11:32

1 Answer 1

0

Converting my comment to an answer. You can use following find + xargs pipeline command:

cd /parent/dir

find home -name "*.orc" -print0 | xargs -0 cat > test.orc 
Sign up to request clarification or add additional context in comments.

1 Comment

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.