免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: ssxy2009
打印 上一主题 下一主题

怎样去除文件里面的隐藏字符???????help!!! [复制链接]

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
31 [报告]
发表于 2010-08-27 15:18 |只看该作者
A for all
cat --help

论坛徽章:
16
IT运维版块每日发帖之星
日期:2015-08-24 06:20:00综合交流区版块每日发帖之星
日期:2015-10-14 06:20:00IT运维版块每日发帖之星
日期:2015-10-25 06:20:00IT运维版块每日发帖之星
日期:2015-11-06 06:20:00IT运维版块每日发帖之星
日期:2015-12-10 06:20:00平安夜徽章
日期:2015-12-26 00:06:302016猴年福章徽章
日期:2016-02-18 15:30:34IT运维版块每日发帖之星
日期:2016-04-15 06:20:00IT运维版块每日发帖之星
日期:2016-05-21 06:20:00综合交流区版块每日发帖之星
日期:2016-08-16 06:20:002015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-08-14 06:20:00
32 [报告]
发表于 2010-08-27 15:24 |只看该作者
回复 29# 论坛ID


    -i

论坛徽章:
0
33 [报告]
发表于 2010-08-27 15:32 |只看该作者
本帖最后由 论坛ID 于 2010-09-15 09:47 编辑

回复 32# expert1


    原来是打错了,尴尬阿

论坛徽章:
0
34 [报告]
发表于 2010-08-27 15:40 |只看该作者
回复 24# expert1


    同时按住ctrl +v,然后释放v,再按下大键盘的数字6,最后同时释放、回车就出来了吧

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
35 [报告]
发表于 2010-08-27 15:41 |只看该作者
i for in place

论坛徽章:
0
36 [报告]
发表于 2010-08-27 16:30 |只看该作者
回复  expert1


    同时按住ctrl +v,然后释放v,再按下大键盘的数字6,最后同时释放、回车就出来了吧 ...
vbirding 发表于 2010-08-27 15:40



    靠,说的太复杂了吧

直接说同时按下ctrl v m就ok了

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:50:282015年亚洲杯之朝鲜
日期:2015-03-13 22:47:33IT运维版块每日发帖之星
日期:2016-01-09 06:20:00IT运维版块每周发帖之星
日期:2016-03-07 16:27:44
37 [报告]
发表于 2010-08-27 17:08 |只看该作者
dos格式啊。

论坛徽章:
0
38 [报告]
发表于 2010-08-27 17:11 |只看该作者
我啥也不说了

论坛徽章:
0
39 [报告]
发表于 2010-08-27 17:43 |只看该作者
faq
打个标,以后建faq的时候可能用得上

论坛徽章:
0
40 [报告]
发表于 2010-08-28 14:42 |只看该作者
本帖最后由 xiaopan3322 于 2010-08-28 14:46 编辑

回复 1# ssxy2009


    这玩意是windows下的carriage return ( ^M )
    想移调,直接用 dos2unix 呗
    要么直接vi里面改:
  1. :1,$s/^M//g
复制代码
或者
  1. :%s/^M//g
复制代码
算了,干脆copy paste一下怎么转换windows和unix格式的文本文件吧:

How to convert between Unix and Windows text files?

The format of Windows and Unix text files differs slightly. In Windows, lines end with both the line feed and carriage return ASCII characters, but Unix uses only a line feed. As a consequence, some Windows applications will not show the line breaks in Unix-format files. Likewise, Unix programs may display the carriage returns in Windows text files with Ctrl-m ( ^M ) characters at the end of each line.

There are many ways to solve this problem. This document provides instructions for using FTP, screen capture, unix2dos and dos2unix, tr, awk, Perl, and vi to do the conversion. To use these utilities, the files you are converting must be on a Unix computer.

Note: In the instructions below, replace unixfile.txt with the name of your Unix file, and replace winfile.txt with the Windows filename..

FTP

When using an FTP program to move a text file between Unix and Windows, be sure the file is transferred in ASCII format, so the document is transformed into a text format appropriate for the host. Some FTP programs, especially graphical applications (e.g., Hummingbird FTP), do this automatically. If you are using command line FTP, before you begin the transfer, enter:
ascii

Note: You need to use a client that supports secure FTP to transfer files to and from Indiana University's central systems. For more, see At IU, what SSH/SFTP clients are supported and where can I get them?

dos2unix and unix2dos

On Solaris systems, the utilities dos2unix and unix2dos are available for converting files from the Unix command line.

To convert a Windows file to a Unix file, enter:
dos2unix winfile.txt unixfile.txt

To convert a Unix file to Windows, enter:
unix2dos unixfile.txt winfile.txt

Note: These utilities are available only on Solaris systems.

tr

You can use tr to remove all carriage returns and Ctrl-z ( ^Z ) characters from a Windows file:
tr -d '\15\32' < winfile.txt > unixfile.txt

However, you cannot use tr to convert a document from Unix format to Windows.
awk

To use awk to convert a Windows file to Unix, enter:
awk '{ sub("\r$", ""); print }' winfile.txt > unixfile.txt

To convert a Unix file to Windows, enter:
awk 'sub("$", "\r")' unixfile.txt > winfile.txt

Older versions of awk do not include the sub function. In such cases, use the same command, but replace awk with gawk or nawk.
Perl


To convert a Windows text file to a Unix text file using Perl, enter:
perl -p -e 's/\r$//' < winfile.txt > unixfile.txt

To convert from a Unix text file to a Windows text file, enter:
perl -p -e 's/\n/\r\n/' < unixfile.txt > winfile.txt

You must use single quotation marks in either command line. This prevents your shell from trying to evaluate anything inside.
vi


In vi, you can remove carriage return ( ^M ) characters with the following command:
:1,$s/^M//g

Note: To input the ^M character, press Ctrl-v , and then press Enter or return.

In vim, use :set ff=unix to convert to Unix; use :set ff=dos to convert to Windows.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP