Spaces between the lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Spaces between the lines
# 1  
Old 05-06-2014
Blade Spaces between the lines

How to get spaces between the two lines

I have file

File1
A.txt
B.txt

File2
C.txt
D.txt

Doing cat and appending to one file i.e file3

when i was doing append i need output like below


File3

File1
A.txt
B.txt

File2
C.txt
D.txt


see above i need space between cotent of files
# 2  
Old 05-06-2014
Longhand purely from the command line; OSX 10.7.5 default bash terminal...
Assumption:- "file1" and "file2" is not needed in the appended final file.
Code:
Last login: Tue May  6 21:11:18 on ttys000
AMIGA:barrywalker~> echo "A.txt
> B.txt" > /tmp/file1
AMIGA:barrywalker~> echo "C.txt
> D.txt" > /tmp/file2
AMIGA:barrywalker~> cat < /tmp/file1 > /tmp/file3
AMIGA:barrywalker~> echo "" >> /tmp/file3
AMIGA:barrywalker~> cat < /tmp/file2 >> /tmp/file3
AMIGA:barrywalker~> cat < /tmp/file3
A.txt
B.txt

C.txt
D.txt
AMIGA:barrywalker~> _

# 3  
Old 05-06-2014
try also:
Code:
awk 'FNR==1 {print ""}; 1' File1 File2 > File3

# 4  
Old 05-08-2014
You could also create a dummy file and include that:-
Code:
echo > /tmp/dummy
cat file1 /tmp/dummy file2

Note that touch /tmp/dummy or just >/tmp/dummywill create an empty file and this will not work. You need a file to include the carriage return. Depending on your OS, you may need to use print >/tmp/dummy instead.



Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing certain positions in lines with spaces

Hello, I have a file with hundreds of lines. Now I need to replace positions 750-766 in each line (whatever there is there) with spaces... how can I do that? Which command to use? The result will be all the lines in the file will have spaces in positions 750-766. Thanks! (3 Replies)
Discussion started by: netrom
3 Replies

2. Shell Programming and Scripting

Reform Lines in File without blank lines and spaces

Hello All, I have a file with data as below. Each line consists of 21 fields. I am not able to load them back to the database. 50733339,"834","834 ","005010X279A1","N","Y","007977163","0001 ",30,"2110D ","EB ","EB007 ","2 ","Conditional Required Data Element Miss ing... (3 Replies)
Discussion started by: Praveenkulkarni
3 Replies

3. Shell Programming and Scripting

remove spaces and lines that start with --

Is it possible to remove empty lines between >humid-sets (bold) and also humidset that start with -- (for ex: > humid3 | () : | (+) ) Thanx in advance Note: The humid sets will be in thousands and lines will be more than 100 thousand. input > humid1 | () : | (+)... (7 Replies)
Discussion started by: quincyjones
7 Replies

4. Shell Programming and Scripting

differentiate between spaces and new-lines

Hi - Here's the problem I'm encountering......My script logs in to remote FTP through password-less "sftp" and must get the list of sub-directories under a given path. I know many of the unix commands don't work in "sftp" login so I cannot know which one is a "directory" and which one is a... (2 Replies)
Discussion started by: dips_ag
2 Replies

5. Shell Programming and Scripting

Having a for loop read in lines with spaces?

Is this possible? I have a for loop in a shell script reading a list, but I want each line to be a loop, not each thing with a space. Here is the example: HOSTLIST="\ 1.2.3.4 serverA 1.2.3.5 serverB" for NBUHOST in `echo $HOSTLIST` do ssh ${SERVERNAME} "echo "${NBUHOST}"... (3 Replies)
Discussion started by: LordJezoX
3 Replies

6. UNIX for Dummies Questions & Answers

using tr to print spaces between lines

hi forum i was wondering can you use tr to print out a file like this i see that there is no way you could do that i feel i see that there is no way you could do that i feel i see that there is no way you could do that i feel i see that there is no way you could do that i feel i see that... (2 Replies)
Discussion started by: ShinTec
2 Replies

7. Shell Programming and Scripting

Spaces in Lines for Variables

All, I am driving myself crazy over this one. I have run a find command against a volume on a nas. That returns a full listing of path and file name. This is an example of one line of output. I redirected the output of the find command to a file. ... (4 Replies)
Discussion started by: bubbwe
4 Replies

8. UNIX for Dummies Questions & Answers

Deleting lines starting with spaces then non-numerals

I did a search but couldn't find a thread that seemed to answer this but my apologies if it has been answered before. I have some text files and I need to remove any line that does not start with a number (0-9). In actuality every line like this starts with a 'T' (or 't') but there are a... (5 Replies)
Discussion started by: skray
5 Replies

9. Shell Programming and Scripting

How to remove plank spaces at the end of lines

Hello friends, I want to remove blank spaces at the end of lines. I use sed command to do this but it is not working correctly. sed ‘s/ $//’ file_name Can some body tell me what is the proper way to remove blank spaces at the end of a limes. Thanks, Mahesh Fernando. (3 Replies)
Discussion started by: maheshsri
3 Replies

10. UNIX for Dummies Questions & Answers

delete blank lines or lines with spaces only

hi there i'm trying to delete blank lines and or lines with spaces only from a series of files in an directory. to do so, i'm using this: for files in `ls /users/myname/pesop* 2>/dev/null` do grep -v ^$ $files > newfile mv newfile $files done now, this works great for blank lines but... (3 Replies)
Discussion started by: vascobrito
3 Replies
Login or Register to Ask a Question