Sponsored Content
Top Forums Shell Programming and Scripting Break lines up into single lines after each space in every line Post 302361873 by vgersh99 on Wednesday 14th of October 2009 09:19:12 AM
Old 10-14-2009
Code:
tr -s ' ' '\n' < myFile

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Joining lines to single line in VI

Dear friends, In VI, I have these data shown below: Line1 Line2 Line3 Line4 How can I JOIN these line to the first line? When I finished I should have: Line1 Line2 Line3 Line4 is there a text length limit of how long a single line can be in VI? Thank you much! (10 Replies)
Discussion started by: bobo
10 Replies

2. Shell Programming and Scripting

Break one line to many lines using awk

Break one line to many lines using awk The below code works but i want to implement without combining field 2 and 3 and then splitting i would like to do this in one command instead of writing multiple commands and creating multiple lines. nawk -F"|" '{print $1,$2SUBSEP$3}' OFS="|" file >... (16 Replies)
Discussion started by: pinnacle
16 Replies

3. Shell Programming and Scripting

join lines on line break in files

i had a file where lines appear to be broken when they shouldn't eg Line 1. kerl abc sdskd sdsjkdlsd sdsdksd \ Line 2. ksdkks sdnjs djsdjsd i can do a shift join to combine the lines but i there are plenty of files with this issue Line 1. kerl abc sdskd sdsjkdlsd sdsdksd ksdkks sdnjs... (6 Replies)
Discussion started by: mad_man12
6 Replies

4. Shell Programming and Scripting

Awk to Break lines to multiple lines.

Input File: nawk -F "|" '{ for(i=1;i<=NF;i++) { if (i == 2) {gsub(",","#",$i);z=split($i,a,"")} else if (i == 3) {gsub(",","#",$i);z=split($i,b,"")} } if(z > 0) for(i=1;i<=z;i++) print $1,a,"Test"; if(w > 0) for(j=1;j<=w;j++) ... (1 Reply)
Discussion started by: pinnacle
1 Replies

5. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

6. Shell Programming and Scripting

Multi lines to single line

HI, My input file contains the data as like below: A1234119993 B6271113 Bghjkjk A1234119992 B6271113hi Bghjkjkmkl the output i require is : A1234119993 B6271113 Bghjkjk A1234119992 B6271113hi Bghjkjkmkl Please help me in this. Thanks (6 Replies)
Discussion started by: pandeesh
6 Replies

7. UNIX for Dummies Questions & Answers

Replacing 2 lines by single line

Hi I have a file with below content : a b S I need to replace the lines which have a and b continuously by d. d S I have used the below code tr '\n' '#'<file|sed. 's/a#b/d/g's?|tr '#' '\n' where # is not occurring anywhere in the file.. Is there any other efficient way to do this? ... (7 Replies)
Discussion started by: pandeesh
7 Replies

8. Shell Programming and Scripting

Write the lines in one single line

Hi, I need some iteration to do the following work. Sample: ANS|26-Jan-2012|26|MON|12536.1 ANS|26-Jan-2012|26|TUE|2536.1 ANS|26-Jan-2012|26|THUR|789.1 SED|26-Jan-2013|32|MON|258.1 SED|26-Jan-2013|32|TUE|369.1 SED|26-Jan-2013|32|THUR|2145.1 OUTPUT: ... (3 Replies)
Discussion started by: anshaa
3 Replies

9. Shell Programming and Scripting

Enumerate lines until each line break using awk

Hi, I have the following data: This this DT 0.99955 0 4 is be VBZ 1 5 7 sentence sentence NN 0.916667 8 16 one one NN 0.545078 17 20 . . Fp 1 20 21 This this DT 0.99955 22 26 is be VBZ 1 27 29 the the DT 1 30 33 second 2 JJ 0.930556 34 40 sentence sentence NN 0.916667 41 49... (1 Reply)
Discussion started by: owwow14
1 Replies

10. Shell Programming and Scripting

Break line content into multiple lines using delimiter

I need to break the line after every 3rd semi colon(;) using Unix shell scripting Input.txt ABC;DEF;JHY;LKU;QWE;BVF;RGHY; Output.txt ABC;DEF;JHY; LKU;QWE;BVF; RGHY; (1 Reply)
Discussion started by: meet_calramz
1 Replies
nl(1)							      General Commands Manual							     nl(1)

Name
       nl - line numbering filter

Syntax
       nl [-h type] [-b type] [-f type] [-v start#] [-i incr] [-p ] [-l num] [-s sep] [-w width] [-n format] [-d delim] file

Description
       The  command reads lines from the named file or from the standard input, if no file is named, and reproduces the lines on the standard out-
       put.  Lines are numbered on the left in accordance with the command options in effect.

       The command views the text it reads in terms of logical pages.  Line numbering is reset at the start of each logical page.  A logical  page
       consists  of  a header, a body, and a footer section.  Empty sections are valid.  Different line numbering options are independently avail-
       able for header, body, and footer.  For example, you can elect not to number header and footer lines while numbering  blank  lines  in  the
       body.

       The start of logical page sections is signaled by input lines containing nothing but the following delimiter characters:

		 Line contents	Start of

		 ::: 	header

		 ::		body

		 :		footer

       Unless otherwise specified, assumes that the text it is reading is in the body of a single logical page.

Options
       Command options may appear in any order and may be intermingled with an optional file name.  Only one file may be named.

       -b type		   Specifies  which  logical page body lines are to be numbered.  The following are recognized types and their meaning: a,
			   number all lines; t, number lines with printable text only; n, no line numbering; pstring, number only lines that  con-
			   tain the regular expression specified in string.

			   The default type for logical page body is t (text lines numbered).

       -h type		   Same as -b type except for header.  Default type for logical page header is n (no lines numbered).

       -f type		   Same as -b type except for footer.  Default for logical page footer is n (no lines numbered).

       -p		   Do not restart numbering at logical page delimiters.

       -v start#	   The initial value used to number logical page lines.  Default is 1.

       -i incr		   The increment value used to number logical page lines.  Default is 1.

       -s sep		   The character used in separating the line number and the corresponding text line.  Default sep is a tab.

       -w width 	   The number of characters used for the line number.  Default width is 6.

       -n format	   The	line  numbering  format.   Recognized values are the following: ln, left justified, leading zeroes suppressed; rn,
			   right justified, leading zeroes suppressed; rz, right justified, leading zeroes kept.  Default format is rn (right jus-
			   tified).

       -l num		   The	number	of  blank lines to be considered as one.  For example, -l2 results in only the second adjacent blank being
			   numbered (if the appropriate -ha, -ba, or -fa option is set).  Default is 1.

       -d xx		   The delimiter characters specifying the start of a logical page section may be changed from the default characters (:)
			   to two user-specified characters.  If only one character is entered, the second character remains the default character
			   (:).  No space should appear between the -d and the delimiter characters.  To enter a  backslash,  you  must  type  two
			   backslashes (//).

Examples
       nl -v10 -i10 -d!+ file1
       This command numbers file1 starting at line number 10 with an increment of ten.	The logical page delimiters are !+.

See Also
       pr(1)

																	     nl(1)
All times are GMT -4. The time now is 03:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy