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)
上一篇 2022年5月31日 下午5:16
下一篇 2022年5月31日 下午5:16


相关推荐

  • 简单几招激活成功教程Windows管理员密码

    简单几招激活成功教程Windows管理员密码相信记忆力炒鸡不好的你 一定经历过这样的窘境 忘记自己的 Windows 开机密码进去系统 或者是调皮捣蛋的你 像我一样 自己没带电脑 却急需电脑 然而面前有一台电脑却被设了开机密码 想进别人电脑并且还不能留痕迹改密码 肿么破肿么破 哈哈废话不多说 下面简单几招教你如何激活成功教程 Windows 开机密码 其实对于一般简单的数字组合密码激活成功教程相对简单 对于较复杂的 像字母数字组合并且位数炒鸡长

    2026年3月18日
    1
  • 用“多智能体协同Agent”一分钟搭建专属研究Agent,帮企业做深度研究

    用“多智能体协同Agent”一分钟搭建专属研究Agent,帮企业做深度研究

    2026年3月15日
    3
  • python 可视化:fig, ax = plt.subplots()画多表图的3中常见样例 & 自定义图表格式

    python 可视化:fig, ax = plt.subplots()画多表图的3中常见样例 & 自定义图表格式目录一、fig,ax=plt.subplots()的作用?二、参数的含义?三、怎么在一个图上排列多个子图?四、怎么把多个子图一起合并到一个图上?《PythonforDataAnalysis》2ndEdition一、fig,ax=plt.subplots()的作用?它是用来创建总画布/figure“窗口”的,有figure就可以在上边(或其中一个子…

    2022年6月16日
    50
  • python协程系列_python协程gevent

    python协程系列_python协程gevent协程协程(Coroutine),又称微线程,纤程。(协程是一种用户态的轻量级线程)作用:在执行A函数的时候,可以随时中断,去执行B函数,然后中断B函数,继续执行A函数(可以自动切换)

    2022年7月29日
    12
  • Springboot的Mybatis拦截器实现[通俗易懂]

    Springboot的Mybatis拦截器实现[通俗易懂]MyBatis提供了一种插件(plugin)的功能,虽然叫做插件,其实就是拦截器功能MyBatis允许拦截的接口MyBatis允许你在已映射语句执行过程中的某一点进行拦截调用。默认情况下,MyBatis允许使用插件来拦截的方法调用包括:Executor(update,query,fl…

    2025年10月11日
    4
  • 微信公众号开发(三)前端界面

    微信公众号开发(三)前端界面由于该公众号主要的用途是用于公司售后服务 经沟通确定相关需求 第一 了解相关的 UI 框架 最终选定了 Jquery WeUI 框架 第二 制作简单案例 在移动端进行测试 要达到移动端的自适应 目前完成三个界面如下 上面的就是目前的界面以及手机适应的效果 后期需要修改 下面的是第一个界面的代码 DOCTYPE tml

    2026年3月18日
    3

发表回复

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

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