简体   繁体   English

Unix:“ ls”命令显示带有?的文件 扩展后

[英]Unix: “ls” command shows files with ? after the extension

I have written a shell script (test.sh) using Java. 我已经使用Java编写了一个Shell脚本(test.sh)。 This shell script actually does a copy job from one file to the other. 此Shell脚本实际上是将一个文件复制到另一个文件。 After the execution of the shell script I have opened the directory from Console and typed ls . 执行完外壳程序脚本后,我从Console打开了目录,并键入ls It shows the output file with ? 显示输出文件 after the extension. 扩展后。

example : foo.csv? 例如:foo.csv?

File execFile = new File(file);
    FileWriter fwFile;
    try {
        fwFile = new FileWriter(execFile);
        execFile.setExecutable(true);
        BufferedWriter bwFile = new BufferedWriter(fwFile);
        bwFile.write(strOutput.substring(0, 2));
        bwFile.write("\r\n");
        bwFile.write("cd " + strOutput);
        bwFile.write("\r\n");
        bwFile.write("mkdir " + strOutput);
        bwFile.write("\r\n");
        bwFile.write(strUnixPath);
        bwFile.write("\r\n");
        bwFile.write("cd " + strWorkingPath + IPlatinumConstants.FS+"lib"+IPlatinumConstants.FS+"Unx");
        bwFile.write("\r\n");
        bwFile.write("echo Cut Src Start time %time%");
        bwFile.write("\r\n");

                bwFile.write("cp " + " \"" + strSourceFilePath + "\"  \""
                        + strOutput + "copy_A\"");
                bwFile.write("\r\n");

My guess is that, while creating the shell script using java, something needs to taken care of 我的猜测是,在使用Java创建Shell脚本时,需要注意一些事项

bwFile.write("\r\n");

replace these lines with UNIX line endings 用UNIX行尾替换这些行

bwFile.write("\n");

or set the proper line separator 或设置适当的行分隔符

System.setProperty("line.separator", "\n");
bwFile.newLine()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM