Ubuntu安装dos2unix命令

Ubuntu安装dos2unix命令Ubuntu系统打开Windows下生成的文本文件,会在每行的末尾出现’^M’原因就是Windows和Linux的回车符是不同的在Windows下回车符是\r\n回车换行在Linux下回车符是\n最简单、最常用的解决方法是使用dos2unix命令转换:dos2unixfilenameUbuntu下dos2unix和unix2dos命令在tofrodos包中安装:apt-g

大家好,又见面了,我是你们的朋友全栈君。

 

Ubuntu系统打开Windows下生成的文本文件,会在每行的末尾出现’^M’
原因就是Windows和Linux的回车符是不同的
在Windows下回车符是\r\n回车换行
在Linux下回车符是\n
最简单、最常用的解决方法是使用dos2unix命令转换:dos2unix filename
Ubuntu下dos2unix和unix2dos命令在tofrodos包中
安装:apt-get install tofrodos
安装完之后用dos2unix和unix2dos发现还是不能用,原来是Ubuntu10.04里已经不再用这个命令啦,

$ dpkg -L tofrodos
/.
/usr
/usr/bin
/usr/bin/fromdos
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/fromdos.1.gz
/usr/share/doc
/usr/share/doc/tofrodos
/usr/share/doc/tofrodos/NEWS.Debian.gz
/usr/share/doc/tofrodos/tofrodos.html
/usr/share/doc/tofrodos/copyright
/usr/share/doc/tofrodos/changelog.Debian.gz
/usr/share/doc/tofrodos/readme.txt.gz
/usr/bin/todos
/usr/share/man/man1/todos.1.gz

可以看出,改成todos和fromdos了,在Ubuntu网站上http://packages.ubuntu.com/zh-cn/jaunty/tofrodos对tofrodos有如下解释:

Tofrodos comprises one program, “fromdos” alias “todos”, which converts text files to and from these formats. Use “fromdos” to convert DOS text files to the Unix format, and “todos” to convert Unix text files to the DOS format.

这里是对fromdos和todos用法的介绍。这两个命令还是比较容易记的,也好理解,更加人性化。

但是有些地方不得不用老的命令dos2unix和unix2dos,怎么办呢?以下引自一篇文章:

http://blog.csdn.net/HandonFeng/archive/2010/05/08/5569186.aspx
大家可以尝试下:

解决方案之一是下一个busybox编译,然后自己建个符号连接。

我用的是busybox1.15.2,里面包含的了这两个命令:

$ ./busybox
BusyBox v1.15.2 (2010-03-22 11:29:01 CST) multi-call binary
Copyright (C) 1998-2008 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]…
or: function [arguments]…

BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!

Currently defined functions:
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash, awk, basename, beep, blkid,

brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpasswd,

chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw,

cttyhack, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, devmem, df, dhcprelay,

diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, du, dumpkmap, dumpleases, echo,

ed, egrep, eject, env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd, false, fbset,

fbsplash, fdflush, fdformat, fdisk, fgrep, find, findfs, fold, free, freeramdisk, fsck, fsck.minix,

fsync, ftpd, ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip, halt, hd, hdparm, head,

hexdump, hostid, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifenslave, ifplugd,

ifup, inetd, init, insmod, install, ionice, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule,

iptunnel, kbd_mode, kill, killall, killall5, klogd, last, length, less, linux32, linux64, linuxrc, ln,
loadfont, loadkmap, logger, login, logname, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod,

lzmacat, lzop, lzopcat, makedevs, makemime, man, md5sum, mdev, mesg, microcom,

mkdir, mkdosfs, mkfifo, mkfs.minix, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp,

modprobe, more, mount, mountpoint, msh, mt, mv, nameif, nc, netstat, nice, nmeter,

nohup, nslookup, od, openvt, passwd, patch, pgrep, pidof, ping, ping6, pipe_progress,

pivot_root, pkill, popmaildir, poweroff, printenv, printf, ps, pscan, pwd, raidautorun, rdate,

rdev, readahead, readlink, readprofile, realpath, reboot, reformime, renice, reset, resize, rm,

rmdir, rmmod, route, rtcwake, run-parts, runlevel, runsv, runsvdir, rx, script, scriptreplay,

sed, sendmail, seq, setarch, setconsole, setfont, setkeycodes, setlogcons, setsid, setuidgid,

sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, softlimit, sort, split,
start-stop-daemon, stat, strings, stty, su, sulogin, sum, sv, svlogd, swapoff, swapon,

switch_root, sync, sysctl, syslogd, tac, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd,

time, timeout, top, touch, tr, traceroute, true, tty, ttysize, tunctl, udhcpc, udhcpd, udpsvd,

umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unzip, uptime,

usleep, uudecode, uuencode, vconfig, vi, vlock, volname, watch, watchdog, wc, wget, which,



who, whoami, xargs, yes, zcat, zcip

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/138311.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 笔记本没有声音,f1一直亮_为什么笔记本按f1不静音

    笔记本没有声音,f1一直亮_为什么笔记本按f1不静音某个平凡的晚上,博主正准备听会儿音乐却发现怎么也打不开声音,通知键盘左上的F1健一直亮着。几经搜寻终找到如下解决方案:win+r出对话框,然后输出services.msc后会出现如下的界面,然后找到LenovoHotkeyClientLoader,点进去选择重启然后再按F1灯就灭了,还能外放了以上只是经过本人试验的有效方法之一,大家可在遇到类似情况时试一试,有其他更好方法的朋友欢迎在评论区补充。…

    2025年11月22日
    4
  • response中如何设置contentType

    response中如何设置contentTypeajax开发中,常遇到下面的几种情况:1服务端需要返回一段普通文本给客户端2服务端需要返回一段HTML代码给客户端3服务端需要返回一段XML代码给客户端4服务端需要返回一段javascript代码给客户端5服务端需要返回一段json串给客户端================================对于每一种返回类型规范的做法是要在服务端…

    2022年7月19日
    135
  • PyCharm激活码永久有效PyCharm2020.1.4激活码教程-持续更新,一步到位

    PyCharm激活码永久有效PyCharm2020.1.4激活码教程-持续更新,一步到位PyCharm激活码永久有效2020.1.4激活码教程-Windows版永久激活-持续更新,Idea激活码2020.1.4成功激活

    2022年6月19日
    68
  • Mysql实现RowNumber[通俗易懂]

    Mysql实现RowNumber[通俗易懂]http://www.uncletoo.com/html/mysql/1060.html

    2022年6月10日
    49
  • LDAP服务器搭建新手指南[通俗易懂]

    LDAP服务器搭建新手指南[通俗易懂]Normal0false7.8

    2022年5月14日
    264
  • Maven 打包命令遇到的坑

    Maven 打包命令遇到的坑今天做定时任务的时候发现定时任务程序中的resources文件夹下面没有被打进去,导致部署在测试环境启动读取不到配置文件,本以为是框架的问题,原来是自己的问题。根据大神对打包的反编译才发现resouces里面的namespace配置根本没有被打包进去。自以为是的是打包进去了,浪费了一定的时间。那idea下的maven命令为什么是这样呢Cleancompileinstallpac

    2022年5月2日
    41

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号