>I have made a test script that shows the problem:
>x=`echo -n "1234"`
>y="1234"
>echo -n $x > file1
>echo -n $y > file2
>After execution, file1 contains 5 characters; "1234" AND a CR (Hex 0A).
>file2 don't.
Ascii 0x0A is a *line-feed* character, LF.
The carriage-return CR is 0x0D
Quote:>How do I avoid the extra CR when doing command substitution ?.
There is none. Trailing LF characters are stripped from the result
of a command substitution.
To be sure that you are not witnessing a bug (*very* unlikely ),
I have tested under Linux/bash (albeit an earlier version SuSE7.1)
and got the expected results, ie; no trailing LF character.
Please double check that you are not making a mistake somewhere,
try the following program;
#!/usr/bin/bash
x=`echo -n "1234"`
y="1234"
echo -n $x > file1
echo -n $y > file2
Then get the contents of the files via 'od'
od -txCa file2
od -txCa file1
output should be the same in both cases;
0000000 31 32 33 34
1 2 3 4
0000004
Quote:>PS: I'm using the default shell (bash) in SuSE 8.1
It would be impossible anyway in your code given
even if the command substitution was bugged say and left
in the LF because you have the variables unquoted in
the 'echo' statements so the NEWLINEs (as SPACEs and TABs
would be ) will just be treated as argument deliminators
by the shell;
! $ x='1234
Quote:> '
! $ echo -n $x |od -txCa
0000000 31 32 33 34
1 2 3 4
0000004
! $ echo -n "$x" | od -txCa
0000000 31 32 33 34 0a
1 2 3 4 nl
0000005
! $
Quote:>Bo
seeyafrom
laura
--
alt.fan.madonna |news, interviews, discussion, writings
|chat, exchange merchandise, meet fans....
|Get into the groove baby you've got to... check us out!