I'm trying to use sed within a shell script (bash, running ubuntu). The command works fine from the command line, but when I use it within the script, rather than creating a file with the name I've specified, it creates one that ends with a question mark '?' when you use ls, e.g. outfile.cvs? and with '^M' when completing the name with tab, e.g. outfile.cvs^M
Here is my sed command:
sed 's/","/";"/g' infile.cvs >outfile.cvs
Because I then call the outfile for the next step in my script, this is a problem. The file itself looks fine.
Your script appears to CR-LF delimited, perhaps because it was created with an editor on a Windows platform and then transferred to the Linux box? Use todos to convert the script to Unix format. Or:
Converting the script worked! Thanks! I must have opened it in windows at some point; I even thought it might be because the file itself was in dos, but I never considered the possibility that the script itself was formatted wrong. What a stupid mistake! I wish I had asked this question 4 hours ago. THANKS so MUCH!