Add blank line to end of file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Add blank line to end of file
# 1  
Old 07-13-2011
Add blank line to end of file

Alright, so I was looking around a bit on the forum before posting and still don't really understand so I figured I'd post my own question.

I am appending two files using
Code:
cat file_1.txt >> file_2.txt

The problem is that I need a blank line in between the two different text files and it does not do that. How can I add the blank line so it looks like the example below?

file_1.txt has the contents:
line 1 from file_1.txt
line 2 from file_1.txt
line 3 from file_1.txt

file_2.txt has the contents:
line 1 from file_2.txt
line 2 from file_2.txt
line 3 from file_2.txt

and after cat file_1.txt >> file_2.txt I want the output to look like this:
line 1 from file_1.txt
line 2 from file_1.txt
line 3 from file_1.txt

line 1 from file_2.txt
line 2 from file_2.txt
line 3 from file_2.txt

I'm thinking after looking around that it will be some sort of sed command.

Thanks!
# 2  
Old 07-13-2011
Code:
echo >> file_2.txt; cat file_1.txt >> file_2.txt

# 3  
Old 07-13-2011
Quote:
Originally Posted by bartus11
Code:
echo >> file_2.txt; cat file_1.txt >> file_2.txt

Brilliant! That worked, thanks.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Inserting a blank line at the end of a .txt file?

Hi there, I am having this problem: a) I am uploading a txt file from windows (notepad) with some Gaussian 09 command lines; b) Gaussian needs in certain command files, that those files have a blank line at the end of the file! c) I open the command file with vi and no blank line at the of... (2 Replies)
Discussion started by: luismga
2 Replies

2. Shell Programming and Scripting

Add new line at beginning and end of a file

Hi, I have a specific requirement to add text at the beginning and end of a plain text file. I tried to use "sed" with '1i' and '$a' flags but these required two separate "sed" commands separated with "|". I am looking for some command/option to join these two in single command parameter. ... (6 Replies)
Discussion started by: bhupinder08
6 Replies

3. Shell Programming and Scripting

Add name at the end of line in one file

Hi Folks, I want to add one name at the end of one file. Below line i have to add end of line some name... Search_masterlogin=`grep -i $masterlogin passwd.master|awk -F: '{print $1}'` $ grep -i susan passwd.master |awk -F: '{print $1}' susan $ I want to insert one name called... (10 Replies)
Discussion started by: susindram
10 Replies

4. Shell Programming and Scripting

default blank line in end of file

Dear Experts, I have spent my full day looking for the solution..:wall:but could no resolved. Here it goes: I have a txt file say data.txt. The content is shown below: ************** datav1 datav2 datav3 *********** I have shown the blank line knowingly. If I open this txt file using... (12 Replies)
Discussion started by: nrjrasaxena
12 Replies

5. Shell Programming and Scripting

appending a blank line for a group of files at the end

hi, i m having a group of files starting with name 'Itemdelete<timestamp>' . my requirment is to append a blank line at the end of files ,using unix in all the Itemdelete* files with a single unix command without using scripts.can any body put some light to this requiremnt. regards Angel (4 Replies)
Discussion started by: angel12345
4 Replies

6. Shell Programming and Scripting

how to add blank spaces at the end of every record in a file.

hi, Does anyone has any idea in adding few blank spaces at the end of every record in a file. Eg: file.txt Baby Boy Kim 1234 Baby Boy Vik 1334 Desired output:- output.txt Baby Boy Kim 1234 Baby Boy Vik 1334 I want to add 10 blank spaces at the end every record in file.txt (3 Replies)
Discussion started by: techmoris
3 Replies

7. Shell Programming and Scripting

how to add a blank line inside the file

Hi, I need to add a blank line before/above the word "do" in my file. This file contains some other words with "do" segment, such as "done" or "rdonly" and the only instance of "do" as a word. The blank line needs to be added above the actual "do" word. Is there a command which I can use... (4 Replies)
Discussion started by: aoussenko
4 Replies

8. UNIX for Dummies Questions & Answers

How to add new line character at the end of a file

hi all, i have this question: How to add new line character at the end of a file???? i need this because i am loading a file to sybase and i have problems with the last record thanks for your help (5 Replies)
Discussion started by: DebianJ
5 Replies

9. Shell Programming and Scripting

Add a word at the end of each line in a file

Hi I want to read a flat file and add a word/value at the end of each line in the file and store the output in a temporary file. How can i do this? Plz help me with this. Regards, Saurabh (6 Replies)
Discussion started by: bhalotias
6 Replies

10. Shell Programming and Scripting

How to add filename to the end of each line in file

Hi, I'm reading data from comma separated files to DB. Now there is a need to have the name of the input file in each row of that file. How can I do this in unix script? Example: $cat file1 value11,value12, value,13 value21,value22, value,23 value31,value32, value,33 And the result... (2 Replies)
Discussion started by: tmikahan
2 Replies
Login or Register to Ask a Question