Displaying contents with Echo


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Displaying contents with Echo
# 1  
Old 09-04-2012
Displaying contents with Echo

Hello,

How can i display the below ... say
Code:
echo "Start \n Analyse \n ~/temp/input.txt \nStop"

Now my output should look like below

Code:
Start
Analyse
This is from input file
Stop

I tried
Code:
 echo "Start \n Analyse \n $var \nStop

where $var = "~/temp/input.txt".. It did not work out.. Also I tried with eval with echo, it again failed.

Help me printing the characters whats specified in echo and also the contents from my input file. Thanks.
# 2  
Old 09-04-2012
Bug

Try something like this...

Code:
echo -e "Start \n Analyse \n `cat /temp/input.txt` \nStop"

This User Gave Thanks to pamu For This Post:
# 3  
Old 09-04-2012
How I missed it!!! erm... Thanks Pamu..
# 4  
Old 09-04-2012
Consider using printf instead of echo for portability.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If contents of A are in B then move the common contents to C

Hallo Team, I have 2 .csv files file A has 47600 lines and file B has 67000 lines FILEA SD0o9rb01-1d320ddbcc8d220f572739ebed5f58d1-v300g00 SD8bt0101-a0810bfe0e3396060126ec51b30dac0a-v300g00 SD05sce01-cb056af347ed4651f29eb3c3e9addbd6-v300g00... (3 Replies)
Discussion started by: kekanap
3 Replies

2. Shell Programming and Scripting

Echo variable contents into a text file...

Hi all, I am trying to create a script to read my Windows UUIDs and create mounts in fstab. I know there are different and maybe even better ways to mount Windows partitions at boot time, but I always manually create them in fstab successfully. I do a clean install of Ubuntu often and would like to... (2 Replies)
Discussion started by: Ian Pride
2 Replies

3. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

4. Shell Programming and Scripting

Echo not displaying variable in If-Else condition

if then echo "Entry Valid : ${x_oug}" else echo "Entry Invalid : " 0 fi In the above code the 3rd line is not working... it does not print anything I tried following as well .. but no luck! echo "Entry Valid : ... (13 Replies)
Discussion started by: Chetanz
13 Replies

5. UNIX for Dummies Questions & Answers

compare 2 file contents , if same delete 2nd file contents

Give shell script....which takes two file names as input and compares the contents, is both are same delete second file's contents..... I try with "diff"...... but confusion how to use "diff" with if ---else Thanking you (5 Replies)
Discussion started by: krishnampkkm
5 Replies

6. UNIX for Dummies Questions & Answers

How to correctly use an echo inside an echo?

Bit of a weird one i suppose, i want to use an echo inside an echo... For example... i have a script that i want to use to take users input and create another script. Inside this script it creates it also needs to use echos... echo "echo "hello"" >$file echo "echo "goodbye"" >$file ... (3 Replies)
Discussion started by: mokachoka
3 Replies

7. Shell Programming and Scripting

Passing filename as parameter and displaying the file contents

Hi All, Its extremely urgent regarding the following requirement. I have created few files in a directory. I have write a program in shell scripting such that it prompts for the filename . once the filename is entered,it should print the contents of the file. Can anyone help with... (7 Replies)
Discussion started by: radhi2424
7 Replies

8. UNIX for Dummies Questions & Answers

Help displaying contents of Directories - Urgent

I am new to shell programming and have an assignment question which requires me to list the contents of the present working directory in 4 column format and highlight any subdirectories. It then requires me to develop the shell script to accept a directory name as a positional parameter (if no... (1 Reply)
Discussion started by: cjnd1988
1 Replies

9. Shell Programming and Scripting

how to echo the file contents LINE BY LINE

hello, i have a listing (let say ABC) consists of the below: : public database link public synonym role rollback segment : when i run the below for loop, for i in `more ABC` do echo "$i" done it gives me, : public database (4 Replies)
Discussion started by: newbie168
4 Replies

10. Shell Programming and Scripting

echo contents of differing variable names

I'm trying to write a script that reads down a listcontaining various columns, if line1 column 1 != 0 then copy various field to variable field1, then check line1 column2 if > 0 this time copy to variable field2 ... Once all columns checked I want to print the value of each variable if it exists... (2 Replies)
Discussion started by: gefa
2 Replies
Login or Register to Ask a Question