Why the created filename with '?'

Ning Ma

New Member
Joined
Mar 21, 2019
Messages
2
Reaction score
0
Credits
0
Hello there,

I am certainly not a Linux expert. I created a program and run it under Oracle environment to copy a file to a new folder with a new name. When the files are copied the file names always have a '?' at the end, like filename?, not just filename.

Any idea why and how I can get rid of the '?' at the end?

Thanks,
Ning
 


Here is one of the lines I used:

cp -f $(ls -t | head -1) /interface/infnehui/DNEH1I/ipp/po_file_transfer/po_output.xml

filename: po_output.xml? instead of po_output.xml
 
G'day @Ning Ma and welcome to linux.org :)

I am moving this Thread to Command Line where it may gain more help for you.

Good luck

Chris Turner
wizardfromoz
 
If memory serves - I think this may have something to do with the line-endings in your script. I suspect your script has DOS style "\r\n" line-endings instead of the unix style "\n".

If your script contains DOS line-endings, the "\r" character before the "\n" gets interpreted as a part of the preceding command. Which is why your file-names are given a ? at the end.

Try running dos2unix on your script to convert the line endings from DOS style \r\n endings to Unix style \n endings.

The command to use is:
Code:
dos2unix /path/to/yourscript
Where /path/to/yourscript is the path to your script!

If you don't have dos2unix installed by default, it should be available in your distros repos.

You may also want to take a look at the settings/options for whatever text editor you are using to create your scripts and see if there is an option to change the line-endings to Unix-style line-endings, instead of MSDOS style line-endings. Then you won't need to use dos2unix, because your files will already be in the correct format.
 

Members online


Top