English 中文(简体)
Unix印刷运输回报的违约行为是什么? [闭门]
原标题:What is default behavior of printing carriage returns in Unix? [closed]

我看到了关于如何去除这些问题的许多问题,但我没有找到答案,说明为什么它们“放弃”我所有的测试/印刷功能。

因此,从方案角度看,运输回报为什么会增加“九”炮弹。

Edit: Yes I can. I don t mean to rant, but I m wondering what causes carriage returns to print funny.

An example is getting messages from a system that ends all messages with . Then I have to do something like message[length - 2] = ; in C or $str =~ s/ //g in perl.

Edit 2: Unix系统中印刷运输回报的违约行为是什么? 这似乎造成问题,一般需要消除。

最佳回答

因为它们对不必要和不欢迎的系统。

You should take a look at your stty settings too. There are options to handle NL/CR mapping on input and output. On a Linux box, stty -a said:

speed 9600 baud; rows 65; columns 120; line = 0;
intr = ^C; quit = ^; erase = ^?; kill = ^X; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts -cdtrdsr
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

Note -ocrnl, onlcr, -onocr, -onlret, -inlcr, -igncr, -icrnl in particular.

仔细看看看看他们的情况。 如果你保持目前停机坪环境,你可以试验:

saved_tty_settings=$(stty -g)

...tinker with the settings here...

stty $saved_tty_settings

一个问题可能是,你将货物固定下来,以便不再把货物送回终点站。 在此情况下,请打字Control-J。 零打美元——打字面——Control-J。 第一种控制-J型冲锋枪,不论指挥是什么(或无);然后,其余则使用<条码>。 我仍然有一份称为<代码>sane<>/code>的文字,有我的首选背景记录,如果我不得不使用。 我过去10年左右经常使用过该信,但我也毫不掩饰。

Do be extremely cautious about using dangerous commands (rm et al) and even using quotes can lead to problem (if you can t see what you ve typed and you lose track and you ve disabled line editing, etc). So, you can play; just be careful.

问题回答

It is because of the different systems interpreting different character combinations to denote end-of-line. Windows uses , *unix used and Mac at one point used . Now when you get Windows created text file in Unx you get extra before and that needs to be removed.

There is a nice utility called dos2unix that handles this format conversion for you.





相关问题
Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Function to create the array by reading the file

I am creating scripts which will store the contents of pipe delimited file. Each column is stored in a separate array. I then read the information from the arrays and process it. There are 20 pipe ...

Compare characters at the end of the string C++

This program supposed to find command line arguments entered on Unix which ends with “.exe”. For some reason it doesn t work. Here is the code: int main( int argc, char* argv[] ) { for ( int ...

Batch Job Dependencies Using Open Source/Free Software

I run a large data warehouse plant where we have a lot of nightly jobs running concerruently however many have dependencies on a extract or data load process before they start. Currently we use an ...

Writing application for both Unix and Windows

I ll write a program for Interactive UNIX (http://en.wikipedia.org/wiki/INTERACTIVE_UNIX). But in a year it will be ported to Windows. I ll write it in ANSI C and/or SH-script. When it runs on Windows ...

Development Environment in Windows [closed]

What are your recommendations for setting up a development environment in Windows, especially when not using an IDE. I am attempting to familiarize myself with Windows, and I feel a bit lost. What ...

热门标签