Problem with echo command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with echo command
# 1  
Old 03-29-2012
Problem with echo command

I am trying to get ascii file using echo command, e.g. -
Code:
echo "\050"

It is correctly working on RHEL 4 but not in RHEL 5. Please help me to fix the issue.

## Working as expected in RHEL 4
Code:
$ lsb_release -d
Description:    Red Hat Enterprise Linux AS release 4 (Nahant Update 8)
$ echo "\050"
(
$

## Not working in RHEL 5
Code:
$ lsb_release -d
Description:    Red Hat Enterprise Linux Server release 5.7 (Tikanga)
$ echo "\050"
\050
$


Thanks
Atanu

Last edited by Franklin52; 03-29-2012 at 02:14 PM.. Reason: Please use code tags for data and code samples, thank you
# 2  
Old 03-29-2012
Try:
Code:
printf "\050\n"

# 3  
Old 03-29-2012
use echo -e "\050"
# 4  
Old 03-29-2012
Some versions of echo interpet \050 by default, some don't.

Some versions of echo support -e, some don't.

Some shell builtin versions of echo have their own behavior, different from the external program's.

printf's behavior, on the other hand, is consistent almost everywhere -- so I recommend it instead of echo here.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 03-29-2012
Bug

echo -e working on both the flavors (rhel 4 n 5), hence, I was thinking to replace "echo" with "echo -e". I have an (wrong) impression that after a small twist I would probably get expected behavior of echo - without using -e switch.

However, since Corona688 adviced printf has consistent behavior, I would probably go for replacing echo with printf.

Thank you very much guys for spending your time helping me to reach the conclusion.

Atanu
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to echo command successful if command is executed successfully

Hello, I have written a command n shell script : srvctl relocate service -d t1 -s s1 -i i1 -t t1 -f If the above command executes successfully without error I need to echo "Service relocated successfully and If it errors out I need to trap the errors in a file and also need to make... (1 Reply)
Discussion started by: Vishal_dba
1 Replies

2. Shell Programming and Scripting

Double echo problem

I'm parsing a router configuration file and printing out some of the fields. Given the following output, I'd like to add the filename to the first column. I'm definately a neophyte in scripting. COUNTER=${#array1 } while ; do ######## echo -n $JUNOS_FILE | ... (3 Replies)
Discussion started by: nocleader
3 Replies

3. Shell Programming and Scripting

echo problem

hi all i have little problem below is my shell script a=`sqlplus fss_cst/fss_cst@dolp1 << EOF SET PAGESIZE 0 FEEDBACK OFF TRIMOUT ON; select process from lfs$ta_process where valid_to_dat=to_date('9/16/2010','mm/dd/yyyy'); EOF` echo ${SQL} the script name is test2.sh when i execute... (5 Replies)
Discussion started by: aishsimplesweet
5 Replies

4. Shell Programming and Scripting

problem with suppressed output to file using echo and tee command

Hi, When I run the following command in terminal it works. The string TEST is appended to a file silently. echo TEST | tee -a file.txt &>/dev/null However, when I paste this same line to a file, say shell1.sh, and use bourne shell . I run this file in terminal, ./shell1.sh. However I... (1 Reply)
Discussion started by: shahanali
1 Replies

5. Shell Programming and Scripting

Problem using echo command for text starting with /

Hi, i need to print following text using echo: /abc dir/c\ so i tried echo "/abc dir/c\ But it gives me error of Incorrect usage, i am using Hamilton cshell in windows Vista. Can any one please help me. Thanks in advance Sarbjit (3 Replies)
Discussion started by: sarbjit
3 Replies

6. Shell Programming and Scripting

Problem with echo *

Hello all, Please help with the below. I have a requirement where in I have to read a pattern and print it as shown below. Patterns will be as below. Input Output Pattern Should be printed as below with spaces such that I can awk. -*--* - * - - * *--**... (2 Replies)
Discussion started by: tenderfoot
2 Replies

7. UNIX for Dummies Questions & Answers

echo $ problem

Hi I am using tcsh. I want display in a file_1 like this. $VARIBALE I gave in a termianl > echo "\$VARIBALE" > file_1 Its not workning. It was giving VARIBALE: Undefined variable. I gave \ before $, but why it was giving undefined varible? Please help me. Thanks in advance (4 Replies)
Discussion started by: chaitubek
4 Replies

8. Shell Programming and Scripting

echo problem

echo "XXXXX" >> /xx/output.txt cat /xx/file.txt| awk '{tony=tony+$1+$2; print tony/$3*100}' >> /xx/output.txt Dear all, In this situation i will have 2 lines in the output file. What i want is to have only one output line. e.g: XXXXX "value" HOW to put the output of the "cat and awk" in... (1 Reply)
Discussion started by: tontal
1 Replies

9. Shell Programming and Scripting

echo problem

Hi, I have given the following statement in a script to put the values of variables (VAR1, VAR2,...) in a file. echo " $VAR1 $VAR2 $VAR3 $VAR4 $VAR5" >> filename But the output is not coming properly. Variables VAR5, VAR4 are replacing the first (VAR1, VAR2,..). I can't... (5 Replies)
Discussion started by: abrd600
5 Replies

10. UNIX for Dummies Questions & Answers

`echo` problem.

Have the following lines in a script: echo "-----------------------------------------------"\ "---------------------" >> $xdfrpt echo "- Date - - / - /stand - /u - /u1 - /u2 -"\ "/x1 - /x2 - /x3 -" >> $xdfrpt echo... (1 Reply)
Discussion started by: Cameron
1 Replies
Login or Register to Ask a Question