• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

unix

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i concatenate file1 and file2 in a new file called" result" with a blank line between the data of two files?
cat file1 file2 >> result
I dont know how ot get the blank line
 
Marshal
Posts: 71023
291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please always let the subject line tell us what the threa‍d is about.
What happens if you interpose '\n' between the two file names?
 
Saloon Keeper
Posts: 22780
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:What happens if you interpose '\n' between the two file names?



Nothing good.

But how about this?


The pair of double-quotes on the "echo" statement shouldn't be essential. But it does accent the fact that you're interjecting a bare line into the pipe where "-" in the cat command can pick it up.

And just in case there's confusion, I should point out that ">>result" appends all of the about to whatever was already in result. If you wanted result to be only the two files with intervening line, then you'd use ">", not ">>".
 
I found some pretty shells, some sea glass and this lovely tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic