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

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

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