Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Bash脚本,用于将给定类型的所有文件从Unix格式转换为Dos格式 我需要能够在CCE+和Windows之间来回切换,以开发两个系统上的C++项目。我希望能够将给定类型的所有文件(如*.cpp、*.h或*.txt)从Unix转换为Dos_Linux_Windows_Bash_Unix - Fatal编程技术网

Linux Bash脚本,用于将给定类型的所有文件从Unix格式转换为Dos格式 我需要能够在CCE+和Windows之间来回切换,以开发两个系统上的C++项目。我希望能够将给定类型的所有文件(如*.cpp、*.h或*.txt)从Unix转换为Dos

Linux Bash脚本,用于将给定类型的所有文件从Unix格式转换为Dos格式 我需要能够在CCE+和Windows之间来回切换,以开发两个系统上的C++项目。我希望能够将给定类型的所有文件(如*.cpp、*.h或*.txt)从Unix转换为Dos,linux,windows,bash,unix,Linux,Windows,Bash,Unix,我有一个转换单个文件的bash脚本,但我希望能够键入文件类型的扩展名或*.FILETYPE来转换给定目录中该类型的所有文件 这是工作脚本,我需要做什么才能使它一次工作多个文件。我尝试使用for循环,但出现语法错误 #! /bin/sh # Convert a text based file from Unix Format to Dos Format # The Output file should be the name of the input file with # WF inserte

我有一个转换单个文件的bash脚本,但我希望能够键入文件类型的扩展名或*.FILETYPE来转换给定目录中该类型的所有文件

这是工作脚本,我需要做什么才能使它一次工作多个文件。我尝试使用for循环,但出现语法错误

#! /bin/sh

# Convert a text based file from Unix Format to Dos Format
# The Output file should be the name of the input file with
# WF inserted before the file extention
#
# Examples
#    convert Unix format abc.txt to abcWF.txt Windows Format 
#    convert Unix format abc.cpp to abcWF.cpp Windows Format 

echo "In u2w FileToConvert = $1"
    FileBase=$(basename $1)
    FileExtension="${FileBase##*.}"
    FileBase="${FileBase%.*}"
    OutputSuffix="WF.$FileExtension"
    OutputFile="$FileBase$OutputSuffix"
    commandment="unix2dos -n $1 $OutputFile"
    echo $commandment
    unix2dos -n $1 $OutputFile
    echo "diff -w $1 $OutputFile"
    diff -w "$1" "$OutputFile"

exit
示例运行

$  bd2w TestResults.txt
In u2w FileToConvert = TestResults.txt
unix2dos -n TestResults.txt TestResultsWF.txt
unix2dos: converting file TestResults.txt to file TestResultsWF.txt in DOS format ...
diff -w TestResults.txt TestResultsWF.txt

将脚本包装在“$@”循环中的
for file中,并将所有提到的
$1
替换为
$file

#!/bin/sh

for file in "$@"; do
    echo "In u2w FileToConvert = $file"

    FileBase=$(basename "$file")
    FileExtension="${FileBase##*.}"
    FileBase="${FileBase%.*}"
    OutputSuffix="WF.$FileExtension"
    OutputFile="$FileBase$OutputSuffix"

    echo "unix2dos -n $file $OutputFile"
    unix2dos -n "$file" "$OutputFile"

    echo "diff -w $file $OutputFile"
    diff -w "$file" "$OutputFile"
done

将脚本包装在“$@”
循环中的
for file中,并将所有提到的
$1
替换为
$file

#!/bin/sh

for file in "$@"; do
    echo "In u2w FileToConvert = $file"

    FileBase=$(basename "$file")
    FileExtension="${FileBase##*.}"
    FileBase="${FileBase%.*}"
    OutputSuffix="WF.$FileExtension"
    OutputFile="$FileBase$OutputSuffix"

    echo "unix2dos -n $file $OutputFile"
    unix2dos -n "$file" "$OutputFile"

    echo "diff -w $file $OutputFile"
    diff -w "$file" "$OutputFile"
done

在Windows上,我将编辑器设置为Unix格式,避免了每次移动后转换文件时出现问题。你能在你的IDE中实现这个吗?你得到了什么错误?你的循环是什么?类似于*.txt中文件的
?错误消息是意外的文件结尾。在Windows上,我通常使用某种形式的visual studio。在Windows上,我将编辑器设置为Unix格式,以避免每次移动后转换文件时出现问题。你能在你的IDE中实现这个吗?你得到了什么错误?你的循环是什么?类似于*.txt中文件的
?错误消息是意外的文件结尾。在Windows上,我通常使用某种形式的visual studio。“$@”是脚本参数列表“$@”是脚本参数列表