dos2unix

\377\376 Appended to file (Windows -> Unix)

不想你离开。 提交于 2020-01-11 09:58:06
问题 Morning All - I have a problem and the solution has alluded me for a few days now. I have an SSIS package that performs the following. 1. Run SQL script 2. Export results to flat file (UTF-8 Encoded, ; delimitated, and \n for new lines) 3. FTP results to solaris machine ( binary format ) The problem is, that when the file is shows up on my solaris box it has the following at the start of the file. \377\376 I have tried dos2unix and still has not corrected the issue. In fact it changes the

Convert expect output from DOS to UNIX style in realtime

本秂侑毒 提交于 2019-12-25 05:32:18
问题 I write some expect scripts by connecting to a remote host through serial connection. My problem is that the output of the spawned process (enabled with log_user 1 ) contains DOS-style endings (each line being terminated with ^M when reading logs in VIM). I normally run dos2unix on all logs at the end of the expect session, to get rid of them. Can the conversion be done in real time? 回答1: It turned out the problem is really simple. What I am doing with my scripts is calling them like below:

Dos2unix not working when trying to silence command

六月ゝ 毕业季﹏ 提交于 2019-12-23 13:58:14
问题 I was calling dos2unix from within Python this way: call("dos2unix " + file1, shell=True, stdout=PIPE) However to silence the Unix output, I did this: f_null = open(os.devnull, 'w') call("dos2unix " + file1, shell=True, stdout=f_null , stderr=subprocess.STDOUT) This doesn't seem to work. The command isn't being called anymore as the diff that I perform on the file1 against file2 (did a diff -y file1 file2 | cat -t and could see the line endings hadn't changed). file2 is the file I am

dos2unix doesn't convert ^M

℡╲_俬逩灬. 提交于 2019-12-20 18:09:19
问题 I exported results in a text file from a program running on Windows 7, and copied the file on Xubuntu 14.04. In a terminal, I ran dos2unix file.txt , which tells me converting file out_mapqtl.txt to Unix format . However, when I look at the file with less , I still see the Windows end-of-line as ^M, and wc -l returns me "0". I tried several things described here, but none works. I then opened the file in Vim and did :%s/\r/\r/g as explained there, which worked fine. So any idea why dos2unix

Convert files to UNIX format using Maven

大城市里の小女人 提交于 2019-12-18 11:25:22
问题 I have an application that is developed in a Windows environment. The application itself gets deployed to a Linux environment. Each time I deploy this application I have to convert executable files to UNIX format using dos2unix. I originally thought this was caused by the Windows CP1252 encoding, so I updated Maven to encode the files to UTF-8. This didn't solve my issue and I quickly found out that this has to do with carriage returns and line feeds by searching this site. Is there a way to

Anything like dos2unix for Windows?

橙三吉。 提交于 2019-12-17 16:34:45
问题 I have some shell scripts created on windows I want to run dos2unix on them. But as I have read that dos2unix works in Linux environment so, is there a way that I can convert my files to UNIX format while working in Windows? I have already installed CYGWIN but I am facing some issues as Administrator@SGH735082N ~ $ pwd /home/Administrator Administrator@SGH735082N ~ $ cd C:\CVS Code Administrator@SGH735082N /cygdrive/c/CVS $ dos2Unix BLPDB000 BLPDB000: dos2Unix processing BLPDB000: No such

Convert line endings [duplicate]

大城市里の小女人 提交于 2019-12-17 06:27:32
问题 This question already has answers here : How to convert DOS/Windows newline (CRLF) to Unix newline (LF) in a Bash script? (22 answers) Closed 5 years ago . I have been using d2u to convert line endings. After installing Puppy Linux I noticed that it does not come with d2u , but dos2unix . Then I noticed that Ubuntu is missing both by default. What is another way to convert line endings? 回答1: Some options: Using tr tr -d '\15\32' < windows.txt > unix.txt OR tr -d '\r' < windows.txt > unix.txt

如何使用sed替换换行符(\\ n)?

风流意气都作罢 提交于 2019-12-09 17:36:06
如何将换行符(“ \\n ”)替换为空格(“ “)使用 sed 命令? 我尝试失败: sed 's#\n# #g' file sed 's#^$# #g' file 我如何解决它? #1楼 sed 旨在用于基于行的输入。 虽然它可以满足您的需求。 更好的选择是使用 tr 命令,如下所示: tr '\n' ' ' < input_filename 或完全删除换行符: tr -d '\n' < input.txt > output.txt 或您是否拥有GNU版本(及其长选项) tr --delete '\n' < input.txt > output.txt #2楼 Perl 版本以您期望的方式工作。 perl -i -p -e 's/\n//' file 正如评论中指出的那样,值得注意的是此编辑已就位。 -i.bak 会在替换前为您提供原始文件的备份,以防您的 正则表达式 不如您想象的那样聪明。 #3楼 我不是专家,但是我想 sed 您首先需要将下一行添加到模式空间中,使用“ N ”进行bij。 在 sed&awk (Dale Dougherty和Arnold Robbins; O'Reilly 1997; 预览的 第107页)的“高级sed命令”中的“多行模式空间”部分中: multiline Next(N)命令通过读取输入的新行并将其附加到模式空间的内容来创建多行模式空间。

<转> Linux查看文件编码格式及文件编码转换

一世执手 提交于 2019-12-07 00:33:49
如果你需要在Linux 中操作windows下的文件 ,那么你可能会经常遇到文件 编码 转换的问题。Windows中默认的文件 格式是GBK(gb2312),而Linux 一般都是UTF-8。下面介绍一下,在Linux 中如何查看 文件 的编码 及如何进行对文件 进行编码 转换。 查看 文件 编码 在Linux 中查看 文件 编码 可以通过以下几种方式: 1.在Vim 中可以直接查看文件编码 :set fileencoding 即可显示文件编码格式。 如果你只是想查看 其它编码 格式的文件 或者想解决用Vim查看 文件 乱码的问题,那么你可以在 ~/.vimrc 文件 中添加以下内容: set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936 这样,就可以让vim自动识别文件 编码 (可以自动识别UTF-8或者GBK编码 的文件 ),其实就是依照 fileencodings提供的编码 列表尝试,如果没有找到合适的编码 ,就用latin-1(ASCII)编码 打开。 2. enca (如果你的系统中没有安装这个命令,可以用sudo yum install -y enca 安装 )查看 文件 编码 $ enca filename filename: Universal transformation format 8 bits; UTF-8

Windows文本文件的回车换行问题解决

你离开我真会死。 提交于 2019-12-06 08:46:27
在Windows上,文本文件编辑后默认的回车换行都是"\r\n",即回车+换行,行尾是两个字符。 在MacOS上,默认是\r,Linux上默认是\n。 虽然这三种情况的文本文件在三种操作系统都是可以正常显示,但是对于一些软件的配置参数文件读出来的时候就会出错,导致整个软件运行都会失败。比如,在Windows上编辑一个Kubernetes上安装软件的.yaml文件,放到linux上使用kubectl apply -f test.yaml方式运行时就会出错。 怎么办呢? 在Linux上使用dos2unix filename处理一下就可以了。 使用apt install dos2unix就可以在Ubuntu上安装。 dos2unix *.*就可以将当前目录的文件全部处理一遍,还是非常方便的。 来源: oschina 链接: https://my.oschina.net/u/2306127/blog/1921744