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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • keil5安装教程简单易上手

    keil5安装教程简单易上手keil5安装教程简单易上手首先对于开发ARM系列MCU来说常用MDK来进行开发废话不多说。文章最后含F0-F7系列pcak包链接1.下载keil5安装包(内含pack包)链接:https://pan.baidu.com/s/1wUH3K-0bxkLhKcDaL92X5A提取码:mnjb2.安装keil5(1).下载打开安装内容分别为如下如果没看见破解机请解压里面的key压缩包(2).打开安装包界面如下(3).先勾选协议在点击NEXT(4).建议不要安装系统盘自行

    2022年5月23日
    65
  • 物联网服务器_物联网接口

    物联网服务器_物联网接口一、第一次上线本主机于2018年12月23日正式上线,初装了4个设备,管理474只表,由于是手抄改网络抄表不是新安装,考虑到人工再去布线的成本远高于设备成本,因此多用了几个设备,每个设备通道都没有用完。1、设备号为663183的设备在安装后有一个通道在抄读水表的时候有短路发生,那是因为…

    2022年8月31日
    3
  • tensorflow实现DCGAN

    tensorflow实现DCGAN1 DCGAN 的简单总结 Paper nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp http arxiv org abs 1511 06434 github nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp https github com Newmu dcgan code nbsp nbsp theano nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp nbsp https github com carpedm20 DCGAN tensorflow nbsp nbsp tensorflow nbsp nbsp

    2025年10月22日
    2
  • 解决Mplayer播放srt、sub字幕乱码的方法

    解决Mplayer播放srt、sub字幕乱码的方法网上看到解决Mplayer播放srt、sub字幕乱码的方法,试了下,srt可以,效果也不错,虽然字体有点大。sub还没有试,可能还是不行,记得以前摆弄过。1.srt字幕要设置正确编码才行右键菜单—-属性设置—–字幕和OSD,在字幕一栏选择编码:简体中文(CP936),再在下面的多选框中选上”unicode字幕”这项.再在属性设置—–字体下编码选unico

    2022年7月11日
    29
  • STlink下载出现st-link usb communication error解决方法

    STlink下载出现st-link usb communication error解决方法一、下载st-link的老版本固件二、备份:关闭keil软件,备份C:\Keil_v5\ARM\STLink文件夹(此处防止失败)三、拷贝:拷贝已下载的老版本固件到C:\Keil_v5\ARM\STLink文件夹中三、固件升级点击ST-LinkUpgrade.exe,打开st-linkupgrade软件进行固件升级插上st-link固件到电脑,点击Device…

    2025年7月31日
    2
  • 【强化学习】GAIL生成对抗模仿学习详解《Generative adversarial imitation learning》

    【强化学习】GAIL生成对抗模仿学习详解《Generative adversarial imitation learning》通过深度强化学习,我们能够让机器人针对一个任务实现从0到1的学习,但是需要我们定义出reward函数,在很多复杂任务,例如无人驾驶中,很难根据状态特征来建立一个科学合理的reward。人类学习新东西有一个重要的方法就是模仿学习,通过观察别人的动作来模仿学习,不需要知道任务的reward函数。模仿学习就是希望机器能够通过观察模仿专家的行为来进行学习。OpenAI,DeepMind,Google…

    2022年9月19日
    6

发表回复

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

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