相关疑难解决方法(0)

如何确定文件的行结尾

我有一堆(数百个)应该有Unix行结尾的文件.我强烈怀疑其中一些有Windows行结尾,我想以编程方式找出哪些行.

我知道我可以跑了

flip -u
或者在脚本中类似的东西来转换所有东西,但我希望能够识别那些需要先改变的文件.

scripting line-endings

51
推荐指数
4
解决办法
5万
查看次数

Linux - 检查文件末尾是否有换行符

我有两个文件,一个有换行,一个没有:

文件:text_without_newline

$root@kali:/home#cat text_without_empty_line
This is a Testfile
This file does not contain an empty line at the end
$root@kali:/home#
Run Code Online (Sandbox Code Playgroud)

文件:text_with_newline

$root@kali:/home#cat text_with_empty_line
This is a Testfile
This file does contain an empty line at the end

$root@kali:/home#
Run Code Online (Sandbox Code Playgroud)

是否有命令或函数来检查文件末尾是否有换行符?我已经找到了这个解决方案,但它对我不起作用.(编辑:IGNORE:使用preg_match和PHP的解决方案也可以.)

linux carriage-return eof

10
推荐指数
2
解决办法
1万
查看次数

提交subversion时可以修改文本文件吗?

我想在正在提交的文本文件上运行以下脚本:

# Send the commands H and w to ed
# ed will append newline if the file does not end in one
printf "%s\n" H w | ed -s $1

# Strip trailing whitespace
sed -i 's/[ \t]*$//g' $1

# Convert tabs to 4 spaces
sed -i -r "s/\t/    /g" $1
Run Code Online (Sandbox Code Playgroud)

我看到subversion有一个start-commit和pre-commit钩子,但是我不能按照有关如何用上面的脚本处理文本文件的文档.

svn hook

3
推荐指数
1
解决办法
556
查看次数

标签 统计

carriage-return ×1

eof ×1

hook ×1

line-endings ×1

linux ×1

scripting ×1

svn ×1