Carriage return with cat variable


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Carriage return with cat variable
# 8  
Old 09-27-2016
Code:
xns1:/home/vbe $ cat blabla.txt
blablalba
blablalba
blablalba
blablalba
xns1:/home/vbe $ te=$(cat blabla.txt)
xns1:/home/vbe $ echo $te
blablalba blablalba blablalba blablalba
xns1:/home/vbe $ echo "$te"
blablalba
blablalba
blablalba
blablalba
xns1:/home/vbe $

This User Gave Thanks to vbe For This Post:
# 9  
Old 09-27-2016
Quote:
Originally Posted by Arnaudh78
mhhh... I understand, there is another solution?
I suggest echo "$te" as suggested above. The quotes are important.
This User Gave Thanks to Corona688 For This Post:
# 10  
Old 09-27-2016
So, I try to be more clear :

Example (in my file.txt) :
Code:
BLABLA
blablabla
etc...
(I need of line feed)
BLABLA
blablabla
(I need of line feed)
blablabla\
etc...

My script into another file :
Code:
#!/bin/bash

sender="me@example.com"
recipient="you@example.com"
subject="TEST FILE"
server="0.0.0.0"

file=$(I want to read my file with cat or another...with the line feed)

/usr/bin/sendemail -f $sender -t $recipient -u $subject -m $file

SmilieSmilie

---------- Post updated at 12:37 PM ---------- Previous update was at 12:36 PM ----------

Quote:
Originally Posted by Corona688
I suggest echo "$te" as suggested above. The quotes are important.
Quote:
Originally Posted by vbe
Did you try?:
Code:
 echo "$te"

Thank you very much ! That works SmilieSmilie And sorry I didn't understand the quotes...I'm ashamed Smilie
This User Gave Thanks to Arnaudh78 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Remove carriage return

I need to remove the carriage return comes inbetween the record. Need to have CR only at the end. I used the below command. tr -d '\n' < filewithcarriagereturns > filewithoutcarriagereturns But its removing all the CR and giving one line output. Input File: 12345 abcdegh... (11 Replies)
Discussion started by: srvn_saru
11 Replies

2. Shell Programming and Scripting

Remove carriage return from the variable

Hi, I try to handle very large numbers with a bash script. I run ssh command in a remote server and store the output in a local variable. But this output contains a return carriage at the end. So I try to remove it by tr But I can't figure out the right notation with printf. So my problem... (6 Replies)
Discussion started by: Meacham12
6 Replies

3. Shell Programming and Scripting

Substitute \n with carriage return

Hello all, I've a flat file in the following format: AB\001\CDED\001\ABC\001\nEG\001\HIJF\001\EFG\001\nHI\003\HIUL\003\HIJ\003 And I want to substitute \n with the carriage return. Any help is appreciated! Regards, - Seth (8 Replies)
Discussion started by: sethmj
8 Replies

4. Shell Programming and Scripting

Carriage return ksh

Hello, How do i usecarriage return in ksh. I want to do an echo "bla bla" and another echo "bla bla" will appear and replace the first echo on screen. I tried: until ; do echo "bla bla \r" done please advice. Thanks. (3 Replies)
Discussion started by: LiorAmitai
3 Replies

5. Shell Programming and Scripting

2 carriage return within a record

Hi all, need your help in replacing carriage return in a record. Input: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10 1|aa|bb|cc|dd|eee eee|ff|ggggg|hh hhh|iii 2|zz|yy|xx|ww|vv|uu|tt|ss|rr Output: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10... (12 Replies)
Discussion started by: agathaeleanor
12 Replies

6. Shell Programming and Scripting

A variable is including the Carriage Return char...

Hi all, I'm reading a file with this layout: First_Col Second_Col The Second_Col has values as 1000, -1, 10, 43... While reading the file I'm getting the second column value with awk command, but it is including the CR control char. do item_saved=`echo $b | awk '{print... (4 Replies)
Discussion started by: mrreds
4 Replies

7. Shell Programming and Scripting

sqlplus returns leading carriage return into a variable

I am trying to generate some scripts to help manage an Oracle database. When I check the value returned from Oracle it has a leading carriage return in the variable. Is there a way to prevent this? Is there a way to easily strip out the carriage return. See code and output below. ... (7 Replies)
Discussion started by: Panzer993
7 Replies

8. Shell Programming and Scripting

Insert a line including Variable & Carriage Return / sed command as Variable

I want to instert Category:XXXXX into the 2. line something like this should work, but I have somewhere the wrong sytanx. something with the linebreak goes wrong: sed "2i\\${n}Category:$cat\n" Sample: Titel Blahh Blahh abllk sdhsd sjdhf Blahh Blah Blahh Blahh Should look like... (2 Replies)
Discussion started by: lowmaster
2 Replies

9. UNIX for Dummies Questions & Answers

Remove a carriage return at end of variable

Is there a command in unix to remove a carriage return character(^M) at the end of a variable value? (5 Replies)
Discussion started by: flagship99
5 Replies

10. Shell Programming and Scripting

Capture carriage return.

I try to test the carriage return in a variable. $ LENGTH=`expr $VARIABLE : ".*"` will return the length of the variable. But this doesn't work if $VARIABLE has zero length. Any help will be well appreciated. Thanks in advance. Giovanni (4 Replies)
Discussion started by: gio123bg
4 Replies
Login or Register to Ask a Question