|
From: laredotornado on 1 Apr 2008 14:11 Hi, I'm using Fedora Core 6 Linux with shell zsh. I have two files a.txt and b.txt, which I want to concatenate to make a third file, "c.txt". The only difference is in the new file "c.txt", I would like a new first line. Sadly, this doesn't work echo 'first_line' | xargs cat a.txt b.txt > c.txt What can I do? Thanks, - Dave
From: pk on 1 Apr 2008 14:37 laredotornado wrote: > Hi, > > I'm using Fedora Core 6 Linux with shell zsh. I have two files a.txt > and b.txt, which I want to concatenate to make a third file, "c.txt". > The only difference is in the new file "c.txt", I would like a new > first line. Sadly, this doesn't work > > echo 'first_line' | xargs cat a.txt b.txt > c.txt A "new first line" is a line to replace a.txt's first line or a completely new, extra line? In the latter case: echo 'first_line' | cat - a.txt b.txt > c.txt In the former case: { echo 'first_line'; tail -n +2 a.txt; } | cat - b.txt > c.txt -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome.
From: Ed Morton on 1 Apr 2008 14:28 On 4/1/2008 1:11 PM, laredotornado wrote: > Hi, > > I'm using Fedora Core 6 Linux with shell zsh. I have two files a.txt > and b.txt, which I want to concatenate to make a third file, "c.txt". > The only difference is in the new file "c.txt", I would like a new > first line. Sadly, this doesn't work > > echo 'first_line' | xargs cat a.txt b.txt > c.txt > > What can I do? Thanks, - Dave { echo 'first_line'; cat a.txt b.txt } > c.txt
From: pk on 1 Apr 2008 14:44 Ed Morton wrote: > { echo 'first_line'; cat a.txt b.txt } > c.txt I think you need a ";" after "b.txt" }, or use round parenthesis instead. -- All the commands are tested with bash and GNU tools, so they may use nonstandard features. I try to mention when something is nonstandard (if I'm aware of that), but I may miss something. Corrections are welcome.
From: Ed Morton on 1 Apr 2008 14:32
On 4/1/2008 1:44 PM, pk wrote: > Ed Morton wrote: > > >>{ echo 'first_line'; cat a.txt b.txt } > c.txt > > > I think you need a ";" after "b.txt" }, or use round parenthesis instead. > Yes. Thanks. Ed. |