HPE 9000 and HPE e3000 Servers
1834009 Members
1680 Online
110063 Solutions
New Discussion

Re: Need to echo output to file greater than 96 characters...

 
SOLVED
Go to solution
Jack C. Mahaffey
Super Advisor

Need to echo output to file greater than 96 characters...

I have a script that uses echo to write output to a file. The text of the message is greater than 96 characters. A cr/lf is being inserted breaking up the line. Text includes directory path. Any ideas? I tried printf and it does the same thing...
jack...
3 REPLIES 3
Ron Kinner
Honored Contributor
Solution

Re: Need to echo output to file greater than 96 characters...

I assume echo /c doesn't help.

You might want to post this in the hp-ux forum instead of under servers. That would be more appropriate and that is also where the big guns hang out.

Ron
A. Clay Stephenson
Acclaimed Contributor

Re: Need to echo output to file greater than 96 characters...

Hi:

Echo should not do this and should ceratinly not insert a CR/LF pair unless being told to do that via \r\n. I suspect that your input data already has the CR/LF pair and what you are seeing is an artifact.

I suggest that you filter your data through dd to remove any CR's and LF's.

e.g.
#!/usr/bin/sh

# assume your input data is in ${XX}

YY=$(echo ${XX} | tr -d "\015\010")
echo ${YY}

I suspect that now the only LF you will see is the one at the end; that can be eliminated with
echo "${YY}\c".

Regards, Clay
If it ain't broke, I can fix that.
Jack C. Mahaffey
Super Advisor

Re: Need to echo output to file greater than 96 characters...

I did some further tracing and realized what I did. The script captured the cr/lf from a previous capture of ll output.

Works fine now. Thanks for the feedback..
jack...