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


相关推荐

  • 测试 windows live writer

    测试 windows live writer

    2021年5月8日
    116
  • 【shell案例】学员管理系统「建议收藏」

    【shell案例】学员管理系统「建议收藏」前言学员管理系统涉及到学员的增删改查,这是一个综合性比较强的项目,在所有的编程语言里都会有不同版本的学员信息管理系统,难度适中效果截图学员管理系统源码#!/bin/bash##随机点名册whiletruedo echo”学生随机点名系统” echo”1.添加学员名单” echo”2.遍历学员名单” echo”3.随机点名” echo”4.删除某个学员的信息” echo”5.退出” read-p”请输入你要选择的序号:”num case

    2022年9月21日
    0
  • 分布式锁的实现和应用场景_predis分布式锁的应用

    分布式锁的实现和应用场景_predis分布式锁的应用文章目录如何理解分布式锁分布式锁的常用实现基于关系型数据库存在单点故障风险不可重入无法实现阻塞应用Redis缓存基于ZooKeeper实现电商网站都会遇到秒杀、特价之类的活动,大促活动有一个共同特点就是访问量激增,在高并发下会出现成千上万人抢购一个商品的场景。虽然在系统设计时会通过限流、异步、排队等方式优化,但整体的并发还是平时的数倍以上,参加活动的商品一般都是限量库存,如何防止库存超卖,避免并发问题呢?分布式锁就是一个解决方案。如何理解分布式锁我们都知道,在业务开发中,为了保证在多线程下处理

    2022年9月7日
    0
  • centos安装教程详解_ensp详细安装步骤

    centos安装教程详解_ensp详细安装步骤Linux中三大主流操作系统Ubuntu优点:用户界面友好、工具完善缺点:vps(虚拟服务器)成本较高、不具备商业化服务器操作系统Centos–目前常用centos6.x,centos7.x

    2022年8月6日
    2
  • JAVA后端开发浅谈[通俗易懂]

    JAVA后端开发浅谈[通俗易懂]一、背景从后端来讲,目前市场上的电子商务软件基本上可以分为两个阵营,即php阵营和Java阵营。两个阵营的开发基本上都是各自围绕着各自的开发语言(php/Java),选取最为兼容合适的框架结构和数据库,然后进行服务器端的开发。以下附上PHP和Java语言的区别介绍和原文链接:《php和java的区别有哪些》php中文网Java语言Java是一门计算机编程语言,和C++、Python等编程…

    2022年7月8日
    27
  • Log4j2 Demos(基础/时间&大小回滚/定期删除/日志脱敏)「建议收藏」

    Log4j2 Demos(基础/时间&大小回滚/定期删除/日志脱敏)「建议收藏」前言本章主要介绍Log4j2的几个例子与使用场景。Log4j2DemosLog4j2Demos(普通设置)<?xmlversion="1.0"encoding="UTF-8"?><Configurationstatus="debug&quo

    2022年5月7日
    55

发表回复

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

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