Odd Shell Echo Output...

I have a simple shell script as follows:

#!/bin/bash
OUTPUT="network.$(date +'%d-%m-%y').info.txt"
SUPPORT_ID="emailaddress"
echo "---------------------------------------------------"  > $OUTPUT
echo "Run date and time: $(date)" >> $OUTPUT
echo "---------------------------------------------------"  >> $OUTPUT
ifconfig >> $OUTPUT
echo "---------------------------------------------------"  >> $OUTPUT
echo "Network info written to file: $OUTPUT."
echo "Please email this file to: $SUPPORT_ID."

It just dumps the network config into a file. At some point I will have the file emailed out, but right now I'm just trying to figure out why the output looks like the following?

bash ./test.sh

.etwork info written to file: network.26-01-25.info.txt
.lease email this file to: emailaddress

Why in the world does the initial character of the last couple of "echo" commands get clipped and turned into periods? The echos for the output of the commands piped into the output file are fine. Strange...

Any ideas?

Answered by MadMacks in 822661022

So I edited the file using Nano (rather than BBEdit and the issue resolved. There must have been some undisplayable code at the beginning of the echo lines that was causing an issue. Very odd. But, after the Nano edit I reopened in BBEdit and turned on invisibles and I don't see any hidden characters. Too bad I didn't check that before I used Nano...

So I edited the file using Nano (rather than BBEdit and the issue resolved. There must have been some undisplayable code at the beginning of the echo lines that was causing an issue. Very odd. But, after the Nano edit I reopened in BBEdit and turned on invisibles and I don't see any hidden characters. Too bad I didn't check that before I used Nano...

I suspect that the issue was that you had BBEdit set to use CR LF line endings. I tried your script here and it worked as expected. I then went to BBEdit, changed the line endings to Windows (CRLF), and retested. The new version reproduced the problem you reported.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yep. And thanks for taking a look.

Odd Shell Echo Output...
 
 
Q