dos和unix文本转化


一 unix/linux 命令

 

unix2dos - UNIX to DOS text file format converter  

 

EXAMPLES

Get input from stdin and write output to stdout.

unix2dos

Convert and replace a.txt. Convert and replace b.txt.

unix2dos a.txt b.txt

unix2dos -o a.txt b.txt

Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode.

unix2dos a.txt -c iso b.txt

unix2dos -c ascii a.txt -c iso b.txt

Convert and replace a.txt while keeping original date stamp.

unix2dos -k a.txt

unix2dos -k -o a.txt

Convert a.txt and write to e.txt.

unix2dos -n a.txt e.txt

Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt.

unix2dos -k -n a.txt e.txt

Convert and replace a.txt. Convert b.txt and write to e.txt.

unix2dos a.txt -n b.txt e.txt

unix2dos -o a.txt -n b.txt e.txt

Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt.

unix2dos -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt

dos2unix - DOS/MAC to UNIX text file format converter

 

 

EXAMPLES

Get input from stdin and write output to stdout.

dos2unix

Convert and replace a.txt. Convert and replace b.txt.

dos2unix a.txt b.txt

dos2unix -o a.txt b.txt

Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format.

dos2unix a.txt -c iso b.txt

dos2unix -c ascii a.txt -c iso b.txt

dos2unix -c mac a.txt b.txt

Convert and replace a.txt while keeping original date stamp.

dos2unix -k a.txt

dos2unix -k -o a.txt

Convert a.txt and write to e.txt.

dos2unix -n a.txt e.txt

Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt.

dos2unix -k -n a.txt e.txt

Convert and replace a.txt. Convert b.txt and write to e.txt.

dos2unix a.txt -n b.txt e.txt

dos2unix -o a.txt -n b.txt e.txt

Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt.

dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt

 

 二 perl脚本

dos2unix.pl

my $file = shift;

if (-$file)
{
  
open IN, "< $file";
  
@DOSFILE = <IN>;
  
close IN;
  
chomp @DOSFILE;
}
else
{
  
print "$file is NOT writable\n";
  
exit 1;
}

open OUT, "> $file";
binmode OUT;

foreach (@DOSFILE)
{
  
print OUT $_;
  
print OUT "\012";
}

close OUT;

 

 unix2dos.pl

 


my $file = shift;

if (-$file)
{
  
open IN, "< $file";
  
@DOSFILE = <IN>;
  
close IN;
  
chomp @DOSFILE;
}
else
{
  
print "$file is NOT writable\n";
  
exit 1;
}

open OUT, "> $file";
binmode OUT;

foreach (@DOSFILE)
{
  
print OUT $_;
  
print OUT "\r\n";
}

close OUT;

 

三 其他工具Tofrodos

 http://www.thefreecountry.com/tofrodos/index.shtml

 

完!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值