0

I hope to draw on the knowledge of those who know far more about scripting than I. I have two files, F1 and F2, where F2 is located in a sub-directory of F1. I need to output a new file, F3, that has the entire contents of F1, followed by the contents of F2 but excluding the first line of F2 (the contents obtained by doing 'tail +2 subdir/F2'). My attempts so far have been fruitless, so any help would be gratefully received.

2 Answers 2

1
cat "F1" > "F3"
tail +2 "subdir/F2" >> "F3"

This will write F1 into F3, and then append the tail output. It's called output redirection.

2
  • Is there any reason not to use cp F1 F3 for the first step? Commented Jan 18, 2012 at 15:38
  • @DennisWilliamson I'm not sure what file attributes cp preserves by default. But you're right, cp "F1" "F3" would also work.
    – Daniel Beck
    Commented Jan 18, 2012 at 15:40
2

You can also use command grouping to obtain a one-liner:

{ cat F1; sed 1d dir/F2; } > F3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .