I had 2 text files and same contains. One text file created by vi and another text file created by shell script.
#!/bin/bash
read -p "Name: " name
read -p "Address: " address
read -p "City: " city
echo -e "Name: " $name"\nAddress: "$address"\nCity: "$city >>test1.txt
I also created one text file test.txt using vi below here:
Name: John
Address: elm street
City: New York
I put a same input in my shell script.
When I compared both text files using diff -d test.txt test1.txt. I got strange characters in text file using shell script. You can see my screen shot below here :
#!/bin/bash
read -p "Name: " name
read -p "Address: " address
read -p "City: " city
echo -e "Name: " $name"\nAddress: "$address"\nCity: "$city >>test1.txt
I also created one text file test.txt using vi below here:
Name: John
Address: elm street
City: New York
I put a same input in my shell script.
When I compared both text files using diff -d test.txt test1.txt. I got strange characters in text file using shell script. You can see my screen shot below here :