Sponsored Content
Top Forums Shell Programming and Scripting Removing carriage return/line feeds on multiple lines Post 302667447 by tomr2012 on Friday 6th of July 2012 10:05:45 AM
Old 07-06-2012
Removing carriage return/line feeds on multiple lines

I would like to remove carriage returns/line feeds in a text file, but in a specific cadence:
  • Read first line (Header Line 1), remove cr/lf at the end (replace it with a space ideally);
  • Read the next line (Line of Text 2), leave the cr/lf intact;
  • Read the next line, remove the cr/lf;
  • Read the next line (Header Line 2), remove cr/lf at the end (replace it with a space);
  • Read the next line (Line of Text 2), leave the cr/lf intact…

Here is my input data, in red of the cr/lf I would like deleted

Code:
Header Line 1 <cr/lf> ( replace with a space)
Line of Text 1<cr/lf>
<cr/lf> 
Header Line 2 <cr/lf> (replace with a space)
Line of Text 2<cr/lf>
<cr/lf>

What I would like to output

Header Line 1 Line of Text 1
Header Line 2 Line of Text 2

Being new to sed, I have managed to remove all the cr/lf’s but I just end up with a long string of text. I would live to preserve the cr/lfs that separate Header Line 1 Line of Text 1 from Header Line 2 Line of Text 2.

Thanks for your help!

Last edited by Scrutinizer; 07-06-2012 at 11:17 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Removing carriage return characters from file

Hello there, I need to remove carriage return characters (\n and \r) from any input file specified. This is what I am doing right now: - dumping the file to octal format using the command 'od -c file_name - removing and \s and \n characters using sed commands What I need to do now is... (3 Replies)
Discussion started by: b1saini
3 Replies

2. Shell Programming and Scripting

carriage return/line feeds

Hello, I have a file that has got carriage returns in it and I want to take them out. Anyone know how I can do this in a ksh? thanks (4 Replies)
Discussion started by: pitstop
4 Replies

3. Shell Programming and Scripting

Removing Carriage return to create one record

I have a file with multiple records in it and want to create a single record by removing all the carriage returns, is there a sed command or another command that will easily allow this to happen. current layout 813209A 813273C 812272B expected result 813209A813273C812272B previously I... (3 Replies)
Discussion started by: r1500
3 Replies

4. Shell Programming and Scripting

sed removing carriage return and newline

Hi, I'm not very familiar with unix shell. I want to replace the combination of two carriage returns and one newline with one carriage return and one newline. I think the best way to do this is to use sed. I tried something like this: sed -e "s#\#\#g" file.txt but it doesn't work. Thanx... (2 Replies)
Discussion started by: mored
2 Replies

5. Shell Programming and Scripting

Removing Carriage Return and or line feed from a file

Hello I'm trying to write a shell script which can remove a carriage return and/or line feed from a file, so the resulting file all ends up on one line. So, I begin with a file like this text in file!<CR> line two!<CR> line three!<CR> END!<CR> And I want to end up with a file... (1 Reply)
Discussion started by: tbone231
1 Replies

6. UNIX for Dummies Questions & Answers

removing spaces after carriage return

I have a file that I have to place a carriage return at the end of each line for another program to process it. I also need to remove all spaces after the carriage return. I searched the forums and found this command, but it removes all spaces: sed "s/*//g" ic527.txt > ic527.new The... (9 Replies)
Discussion started by: jyoung
9 Replies

7. Shell Programming and Scripting

Removing Carriage return and merging data

Hi, I am trying to remove the carriage return on the record which starts with ADD, MODIFY, or DELETE keyword as the first value in the record. If the records does not start with anyone of these keywords then combine the records with the previous record (line). Input File name xyz.txt... (6 Replies)
Discussion started by: naveed
6 Replies

8. Shell Programming and Scripting

Removing Carriage return in a file after particular string

Hi All, I want to remove carriage return in a file using some unix command without writing a script my file is as follows abc1 abc2 abc3 abc4 abc5 bac6 abc1 abc2 abc3 abc4 abc5 bac6 I want the output as follows: abc1 abc2 abc3 abc4 abc5 bac6 abc1 abc2 abc3 abc4 abc5 bac6 , Please... (7 Replies)
Discussion started by: manish8484
7 Replies

9. Shell Programming and Scripting

Bash - multiple line carriage return

Hello! I have one strange question - let's say I have a long, multiple-line string displayed on the terminal using echo, and I would like to make a carriage return to the beginning of this string, no to the beginning of the last line - is something like that possible? I would like to be able to... (1 Reply)
Discussion started by: xqwzts
1 Replies

10. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies
spintime(1)							  [incr Widgets]						       spintime(1)

__________________________________________________________________________________________________________________________________________________

NAME
spintime - Create and manipulate time spinner widgets SYNOPSIS
spintime pathName ?options? INHERITANCE
itk::Widget <- Spintime STANDARD OPTIONS
background cursor foreground relief See the "options" manual entry for details on the standard options. ASSOCIATED OPTIONS
textBackground textFont See the "entryfield" manual entry for details on the above associated options. labelFont labelMargin See the "labeledwidget" manual entry for details on the above associated options. arrowOrient repeatDelay repeatInterval See the "spinner" manual entry for details on the above associated options. WIDGET-SPECIFIC OPTIONS Name: labelPos Class: Position Command-Line Switch: -labelpos Specifies the position of the label along the sides of the various spinners: n, e, s, or w. The default is w. Name: hourLabel Class: Text Command-Line Switch: -hourlabel Specifies the text of the label for the hour spinner. The default is "Hour". Name: hourOn Class: hourOn Command-Line Switch: -houron Specifies whether or not to display the hour spinner in any of the forms acceptable to Tcl_GetBoolean. The default is true. Name: hourWidth Class: Width Command-Line Switch: -hourwidth Specifies the width of the hour spinner in any of the forms acceptable to Tcl_GetPixels. The default is 3 pixels. Name: militaryOn Class: militaryOn Command-Line Switch: -militaryon Specifies use of a 24 hour clock for hour display in any of the forms acceptable to Tcl_GetBoolean. The default is true. Name: minuteLabel Class: Text Command-Line Switch: -minutelabel Specifies the text of the label for the minute spinner. The default is "Minute". Name: minuteOn Class: minuteOn Command-Line Switch: -minuteon Specifies whether or not to display the minute spinner in any of the forms acceptable to Tcl_GetBoolean. The default is true. Name: minuteWidth Class: Width Command-Line Switch: -minutewidth Specifies the width of the minute spinner in any of the forms acceptable to Tcl_GetPixels. The default is 3 pixels. Name: orient Class: Orient Command-Line Switch: -orient Specifies the orientation of the hour, minute, and second spinners: vertical or horizontal. The default is horizontal. Name: secondLabel Class: Text Command-Line Switch: -secondlabel Specifies the text of the label for the second spinner. The default is "Second" Name: secondOn Class: secondOn Command-Line Switch: -secondon Specifies whether or not to display the second spinner in any of the forms acceptable to Tcl_GetBoolean. The default is true. Name: secondWidth Class: Width Command-Line Switch: -secondwidth Specifies the width of the second spinner in any of the forms acceptable to Tcl_GetPixels. The default is 3 pixels. Name: timeMargin Class: Margin Command-Line Switch: -timemargin Specifies the margin space between the hour, minute, and second spinners is any of the forms accpetable to Tcl_GetPixels. The default is 1 pixel. __________________________________________________________________________________________________________________________________________________ DESCRIPTION
The spintime command creates a set of spinners for use in time value entry. The set includes an hour, minute, and second spinner widget. METHODS
The spintime command creates a new Tcl command whose name is pathName. This command may be used to invoke various operations on the widget. It has the following general form: pathName option ?arg arg ...? Option and the args determine the exact behavior of the command. The fol- lowing commands are possible for spintime widgets: WIDGET-SPECIFIC METHODS pathName cget option Returns the current value of the configuration option given by option. Option may have any of the values accepted by the spintime command. pathName configure ?option? ?value option value ...? Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the spintime command. pathName get ?format? Returns the current contents of the spintime widget in a format of string or as an integer clock value using the -string and -clicks format options respectively. The default is by string. Reference the clock command for more information on obtaining time and its formats. pathName show time Changes the currently displayed time to be that of the time argument. The time may be specified either as a string, an integer clock value or the keyword "now". Reference the clock command for more information on obtaining times and its format. COMPONENTS
Name: hour Class: Spinint The hour component is the hour spinner of the time spinner. See the SpinInt widget manual entry for details on the hour component item. Name: minute Class: Spinint The minute component is the minute spinner of the time spinner. See the SpinInt widget manual entry for details on the minute com- ponent item. Name: second Class: Spinint The second component is the second spinner of the time spinner. See the SpinInt widget manual entry for details on the second com- ponent item. EXAMPLE
spintime .st pack .st -padx 10 -pady 10 AUTHOR
Sue Yockey Mark L. Ulferts KEYWORDS
spintime, spinint, spinner, entryfield, entry, widget Tk spintime(1)
All times are GMT -4. The time now is 04:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy