Visit Our UNIX and Linux User Community


echo 2 txt files to screen no carraige return


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting echo 2 txt files to screen no carraige return
# 1  
Old 10-15-2008
echo 2 txt files to screen no carraige return

I have two text files, each of then only containing ONE line and NO carraige return or white space at the end...how do I echo both of these text files to the screen without putting an extra line? I want to do this from the command line.


file1.txt:
this is file1.txt 1

file2.txt:
this is file2.txt 2


I want the output to screen to look something like this:
#
this is file1.txt 1 this is file2.txt 2
#

if I cat the files it looks something like this:
# cat file1.txt file2.txt
this is file1.txt 1
this is file2.txt 2
#

but again, I want the output to be on ONE line.....
# 2  
Old 10-15-2008
Hammer & Screwdriver Here is one approach

Code:
> cat file110
file 110 ends here*
> cat file111
file 111 ends here*
> cat file110 file111 | tr -d "\n" ; echo
file 110 ends here*file 111 ends here*
>

# 3  
Old 10-15-2008
awesome. thank you! that tr -d command is hugely useful!!!
# 4  
Old 10-15-2008
What about paste?
Code:
paste file1.txt file2.txt

# 5  
Old 10-16-2008
Java

As danmero said 'paste' is a good and direct option.

Code:
 paste file1.txt file2.txt

Also you can set the delimter if you don't want to go with tab

Code:
 paste -d ":" file1.txt file2.txt

Also, you can get the normal mode also (using carriage return)

Code:
 paste -s file1.txt file2.txt

Regards
Dileep

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Echo both to the screen and to a file

In shellscript, I want to display echo message in console and in the log file. please help me to display this message in two places. I am using below statment to display messsage, but it is displaying in log file only. echo "Server Already running" >> serverlog 2>&1 (3 Replies)
Discussion started by: Kri
3 Replies

2. Shell Programming and Scripting

How to echo $variable into txt file?

Hello i tried many times echo $variables into text file with no success for example: echo "#!/bin/sh BBHTAG=RFOCLT_check # What we put in bb-hosts to trigger this test COLUMN=RFOCLT # Name of the column, often same as tag in bb-hosts $BBHOME/bin/bbhostgrep $BBHTAG | while read... (5 Replies)
Discussion started by: mogabr
5 Replies

3. Shell Programming and Scripting

echo command with screen and ssh

Hi, i need to execute echo command to write in a txt file on a remote machine. i did it in this way: ssh user@remotemachine "echo "put text here" > /home/user/myfile.txt" I tried to run the same command within a detached screen in this way: ssh user@remotemachine screen -dm "echo "put... (3 Replies)
Discussion started by: brembo
3 Replies

4. Shell Programming and Scripting

Return vs. Echo

In a Ksh functions, when you have both echo and return respectively - what does it do. E.g. Func B () { ..... { ..... echo $Varaible } Return 0 } Func A () { $Var1 = Func B() .... .... } (6 Replies)
Discussion started by: gagan8877
6 Replies

5. Shell Programming and Scripting

perl : stdout is not return to screen

Hello All, I have a perl script , and the STDERR and additional FH is redirected to the STDOUT like below: open STDOUT ,">>$log" or die "$! :: $log\n"; open STDERR ,">&STDOUT" or die "$! :: Can redirect STDERR to STDOUT\n"; select STDERR; $|=1; open LOG ,">&STDOUT" or die "$! :: Can... (2 Replies)
Discussion started by: Alalush
2 Replies

6. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies

7. Shell Programming and Scripting

echo to both screen and a file

Please help me to simplify my below script. #!/bin/bash LOG_FILE=/tmp/log.txt echo "Hello" echo "Hello" >> /tmp/log.txt Is there anyway, that I can echo "Hello" to both screen and file with one single echo command ? (6 Replies)
Discussion started by: phamp008
6 Replies

8. UNIX for Dummies Questions & Answers

set variable to Home, then echo it to screen

Major Newbie here folks. I'm trying to set a variable to my Home directory and then echo it to the screen. Any and all help is greatly appreciated. Thanks Anna (3 Replies)
Discussion started by: amidget
3 Replies

9. UNIX for Dummies Questions & Answers

is it possible to echo 'some text' every 10 minutes on my screen

is it possible to echo 'some text' every 10 minutes on my screen continues , without cron. (1 Reply)
Discussion started by: vkandati
1 Replies

10. UNIX for Dummies Questions & Answers

echo or print to screen and file

I did a search for this topic but I couldn't find it and I was sure I have seen something similar before (hard because I am not sure of the criteria for the keywords) What I was looking for was to be able to echo a message to the screen from a bash.sh script at the same time logging it to a... (2 Replies)
Discussion started by: Shakey21
2 Replies

Featured Tech Videos