Sponsored Content
Full Discussion: replace \r\r\n with \r\n
Top Forums Shell Programming and Scripting replace \r\r\n with \r\n Post 302297695 by hanton on Saturday 14th of March 2009 02:22:28 PM
Old 03-14-2009
I am on SUNos so I use sed

The file is created by an external source. The external source is suppoed to create the file in DOS format but for some reason sometimes they are introduce an extra 0D.

I pick up the file from our server and move it to a folder foR my testing using binary mode SSH client. I open the file in a text editor and I can see 0D 0D 0A. I open it in vi and I can only see one ^M. I though ^M and 0D are the same thing - no?

When I run the tr against a DOS file with 0D 0A it does not remove the 0D -which is what I want.

I am not using cygwin.

One thing - when i view the file in the text editor and go to the end of the line the cursor is on the second 0D. So like this

0D 0D 0A (cursor appears on the bolded 0D)
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to replace ??

Hi all, I have a file with the following data. E01011U, ,E11, , , ,0 E03012U, ,E14, , , ,0 E02013U, ,E25, , , ,0 I want to change it to ('E01-01-1-U','E11' ); ('E03-01-2-U','E14' ); ('E02-01-3-U','E25' ); Please let me know about it .Thanks in advance. (10 Replies)
Discussion started by: preethgideon
10 Replies

2. Shell Programming and Scripting

How to replace into Vi

Ravi . Pawan 19.23 sanjeeva . I want to replace '.' into 'NULL' not the dot between 19.23 .. only single dots to NULL how to do replacement after opening file in Vi (5 Replies)
Discussion started by: ravi.sadani19
5 Replies

3. Shell Programming and Scripting

replace last / by |

Hi: I want to write a Kshell script which will replace last / by |. eg: /home/apps/test/document should be replaced as /home/apps/test|document. The length of the string is not constant. Thanks, Ash (6 Replies)
Discussion started by: naikaa
6 Replies

4. Shell Programming and Scripting

replace

hi i have input file in this format E102|0|1-23-1994|0|12-5-1994|E003|A|10450|charan,devupalli|5000 how to convert this into outfile E102,0,1-23-1994,0,12-5-1994,E003,A,10450,charan,devupalli,5000 i wann the output in excel sheet.........that is why i am converting into csv.. but i have... (6 Replies)
Discussion started by: charandevu
6 Replies

5. Shell Programming and Scripting

Replace Help

Hi, djfksdjk)))) kmmm jfdfjk)))) I want to replace the first ')' after kmmm with #. The output would be djfksdjk)))) exists jfdfjk#))) Can anyone help on this? (3 Replies)
Discussion started by: javeed7
3 Replies

6. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

7. Shell Programming and Scripting

How to replace

Here is my file content age=12 age=34 age=54 age=23 Hello world. This is the age result I am getting. To day date is 23-02-2010. From the above content I have to replace all the values after 'age=*' to age=24. How to do it. (1 Reply)
Discussion started by: brahma
1 Replies

8. Shell Programming and Scripting

Replace dashes positions 351-357 & 024-043 with 0 & replace " " if exis with 04 at position 381-382

I need to replace dashes (i.e. -) if present from positions 351-357 with zero (i.e. 0), I also need to replace dash (i.e “-“) if present between position 024-043 with zero (i.e. 0) & I replace " " (i.e. 2 space characters) if present at position 381-382 with "04". Total length of record is 413.... (11 Replies)
Discussion started by: lancesunny
11 Replies

9. UNIX for Dummies Questions & Answers

How can I replace the lines that start with a star and replace it with numbers start from 1?

I need to replace the (*) in the fist of a list with numbers using sed for example > this file contain a list * linux * computers * labs * questions to >>>> this file contain a list 1. linux 2. computers 3. labs 4. questions (7 Replies)
Discussion started by: aalbazie
7 Replies

10. UNIX for Beginners Questions & Answers

awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy)

I have a csv which has lot of columns . I was looking for an awk script which would extract a column twice. for the first occurance the header and data needs to be intact but for the second occurance i want to replace the header name since it a duplicate and extract year value which is in ddmmyy... (10 Replies)
Discussion started by: Kunalcurious
10 Replies
fconfigure(n)						       Tcl Built-In Commands						     fconfigure(n)

__________________________________________________________________________________________________________________________________________________

NAME
fconfigure - Set and get options on a channel SYNOPSIS
fconfigure channelId fconfigure channelId name fconfigure channelId name value ?name value ...? _________________________________________________________________ DESCRIPTION
The fconfigure command sets and retrieves options for channels. ChannelId identifies the channel for which to set or query an option. If no name or value arguments are supplied, the command returns a list containing alternating option names and values for the channel. If name is supplied but no value then the command returns the current value of the given option. If one or more pairs of name and value are supplied, the command sets each of the named options to the corresponding value; in this case the return value is an empty string. The options described below are supported for all channels. In addition, each channel type may add options that only it supports. See the manual entry for the command that creates each type of channels for the options that that specific type of channel supports. For example, see the manual entry for the socket command for its additional options. -blocking boolean The -blocking option determines whether I/O operations on the channel can cause the process to block indefinitely. The value of the option must be a proper boolean value. Channels are normally in blocking mode; if a channel is placed into nonblocking mode it will affect the operation of the gets, read, puts, flush, and close commands; see the documentation for those commands for details. For nonblocking mode to work correctly, the application must be using the Tcl event loop (e.g. by calling Tcl_DoOneEvent or invoking the vwait command). -buffering newValue If newValue is full then the I/O system will buffer output until its internal buffer is full or until the flush command is invoked. If newValue is line, then the I/O system will automatically flush output for the channel whenever a newline character is output. If newValue is none, the I/O system will flush automatically after every output operation. The default is for -buffering to be set to full except for channels that connect to terminal-like devices; for these channels the initial setting is line. Additionally, stdin and stdout are intially set to line, and stderr is set to none. -buffersize newSize Newvalue must be an integer; its value is used to set the size of buffers, in bytes, subsequently allocated for this channel to store input or output. Newvalue must be between ten and one million, allowing buffers of ten to one million bytes in size. -encoding name | This option is used to specify the encoding of the channel, so that the data can be converted to and from Unicode for use in Tcl. | For instance, in order for Tcl to read characters from a Japanese file in shiftjis and properly process and display the contents, | the encoding would be set to shiftjis. Thereafter, when reading from the channel, the bytes in the Japanese file would be converted | to Unicode as they are read. Writing is also supported - as Tcl strings are written to the channel they will automatically be con- | verted to the specified encoding on output. | If a file contains pure binary data (for instance, a JPEG image), the encoding for the channel should be configured to be binary. | Tcl will then assign no interpretation to the data in the file and simply read or write raw bytes. The Tcl binary command can be | used to manipulate this byte-oriented data. | The default encoding for newly opened channels is the same platform- and locale-dependent system encoding used for interfacing with | the operating system. | -eofchar char -eofchar {inChar outChar} This option supports DOS file systems that use Control-z (x1a) as an end of file marker. If char is not an empty string, then this character signals end-of-file when it is encountered during input. For output, the end-of-file character is output when the channel is closed. If char is the empty string, then there is no special end of file character marker. For read-write channels, a two-ele- ment list specifies the end of file marker for input and output, respectively. As a convenience, when setting the end-of-file char- acter for a read-write channel you can specify a single value that will apply to both reading and writing. When querying the end- of-file character of a read-write channel, a two-element list will always be returned. The default value for -eofchar is the empty string in all cases except for files under Windows. In that case the -eofchar is Control-z (x1a) for reading and the empty string for writing. -translation mode -translation {inMode outMode} In Tcl scripts the end of a line is always represented using a single newline character ( ). However, in actual files and devices the end of a line may be represented differently on different platforms, or even for different devices on the same platform. For example, under UNIX newlines are used in files, whereas carriage-return-linefeed sequences are normally used in network connections. On input (i.e., with gets and read) the Tcl I/O system automatically translates the external end-of-line representation into newline characters. Upon output (i.e., with puts), the I/O system translates newlines to the external end-of-line representation. The default translation mode, auto, handles all the common cases automatically, but the -translation option provides explicit control over the end of line translations. The value associated with -translation is a single item for read-only and write-only channels. The value is a two-element list for read-write channels; the read translation mode is the first element of the list, and the write translation mode is the second ele- ment. As a convenience, when setting the translation mode for a read-write channel you can specify a single value that will apply to both reading and writing. When querying the translation mode of a read-write channel, a two-element list will always be returned. The following values are currently supported: auto As the input translation mode, auto treats any of newline (lf), carriage return (cr), or carriage return followed by a new- line (crlf) as the end of line representation. The end of line representation can even change from line-to-line, and all cases are translated to a newline. As the output translation mode, auto chooses a platform specific representation; for sockets on all platforms Tcl chooses crlf, for all Unix flavors, it chooses lf, for the Macintosh platform it chooses cr and for the various flavors of Windows it chooses crlf. The default setting for -translation is auto for both input and output. binary | No end-of-line translations are performed. This is nearly identical to lf mode, except that in addition binary mode also | sets the end-of-file character to the empty string (which disables it) and sets the encoding to binary (which disables encod- | ing filtering). See the description of -eofchar and -encoding for more information. cr The end of a line in the underlying file or device is represented by a single carriage return character. As the input trans- lation mode, cr mode converts carriage returns to newline characters. As the output translation mode, cr mode translates newline characters to carriage returns. This mode is typically used on Macintosh platforms. crlf The end of a line in the underlying file or device is represented by a carriage return character followed by a linefeed char- acter. As the input translation mode, crlf mode converts carriage-return-linefeed sequences to newline characters. As the output translation mode, crlf mode translates newline characters to carriage-return-linefeed sequences. This mode is typi- cally used on Windows platforms and for network connections. lf The end of a line in the underlying file or device is represented by a single newline (linefeed) character. In this mode no translations occur during either input or output. This mode is typically used on UNIX platforms. SEE ALSO
close(n), flush(n), gets(n), puts(n), read(n), socket(n) KEYWORDS
blocking, buffering, carriage return, end of line, flushing, linemode, newline, nonblocking, platform, translation, encoding, filter, byte array, binary Tcl 8.1 fconfigure(n)
All times are GMT -4. The time now is 10:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy