Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Remove line breaks and extra spaces Post 302999571 by rsi.245 on Thursday 22nd of June 2017 03:05:36 PM
Old 06-22-2017
Remove line breaks and extra spaces

Hi,
I want to remove all extra spaces, line breaks .
Need a new line entry only for term starting"array"

For eg: my input is
Code:
array([ 0.03015278,  0.02738889,  0.0125    ,  0.00875   ,  0.00736806,
        0.00672917,  0.00763889,  0.01044444,  0.01178472,  0.01470139,
        0.02020833,  0.03288194,  0.05940278,  0.03489583,  0.01829167,
        0.01255556,  0.00811111,  0.00670139,  0.00543056,  0.00570139,
        0.00616667,  0.00821528,  0.01138889,  0.02573611,  0.03044444,
        0.57640972]), 
array([ 0.03372518,  0.03230408,  0.00867816,  0.00548067,  0.00434692,
        0.00423197,  0.00397074,  0.0049373 ,  0.00669279,  0.01053292,
        0.0149373 ,  0.02205329,  0.03096134,  0.01904389,  0.009279  ,
        0.00683386,  0.00335946,  0.00386102,  0.00250261,  0.0030303 ,
        0.00272727,  0.00426332,  0.00734587,  0.03399164,  0.05005747,
        0.67085162]), 
array([ 0.035     ,  0.03807317,  0.01169512,  0.00759146,  0.00479878,
        0.00514634,  0.0037378 ,  0.00606707,  0.00528049,  0.00892683,
        0.00631707,  0.01397561,  0.01756098,  0.0159939 ,  0.00477439,
        0.00714024,  0.00343293,  0.00530488,  0.00282927,  0.00380488,
        0.00390854,  0.00551829,  0.00696951,  0.03689634,  0.0427439 ,
        0.6965122 ]),


and my expected output is

Code:
array([ 0.03015278, 0.02738889, 0.0125 , 0.00875 , 0.00736806, 0.00672917, 0.00763889, 0.01044444, 0.01178472, 0.01470139, 0.02020833, 0.03288194, 0.05940278, 0.03489583, 0.01829167, 0.01255556, 0.00811111, 0.00670139, 0.00543056, 0.00570139, 0.00616667, 0.00821528, 0.01138889, 0.02573611, 0.03044444, 0.57640972]), 
array([ 0.03372518, 0.03230408, 0.00867816, 0.00548067, 0.00434692, 0.00423197, 0.00397074, 0.0049373 , 0.00669279, 0.01053292, 0.0149373 , 0.02205329, 0.03096134, 0.01904389, 0.009279 , 0.00683386, 0.00335946, 0.00386102, 0.00250261, 0.0030303 , 0.00272727, 0.00426332, 0.00734587, 0.03399164, 0.05005747, 0.67085162]), 
array([ 0.035 , 0.03807317, 0.01169512, 0.00759146, 0.00479878, 0.00514634, 0.0037378 , 0.00606707, 0.00528049, 0.00892683, 0.00631707, 0.01397561, 0.01756098, 0.0159939 , 0.00477439, 0.00714024, 0.00343293, 0.00530488, 0.00282927, 0.00380488, 0.00390854, 0.00551829, 0.00696951, 0.03689634, 0.0427439 , 0.6965122 ]),

Is it possible using awk?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

To remove the extra spaces in unix

Hi... I am quite new to Unix and would like an issue to be resolved. I have a file in the format below; 4,Reclaim,ECXTEST02,abc123,Harry Potter,5432 6730 0327 5469,0603,,MC,,1200,EUR,sho-001,,1,,,abc123,1223 I would like my output to be as follows; 4,Reclaim,ECXTEST02,abc123,Harry... (4 Replies)
Discussion started by: Sho
4 Replies

2. Shell Programming and Scripting

Remove extra spaces in a line

Hi, I need a help in deleting extra spaces in a text. I have a huge file, a part of it is :- 3 09/21/08 03:32:07 started undef mino Oracle nmx004.wwdc.numonyx.com Message Text : The Oracle session with the PID 1103 has a CPU time ... (6 Replies)
Discussion started by: vikas027
6 Replies

3. Shell Programming and Scripting

any better way to remove line breaks

Hi, I got some log files which print the whole xml message in separate lines: e.g. 2008-10-01 14:21:44,561 INFO do something 2008-10-01 14:21:44,561 INFO print xml : <?xml version="1.0" encoding="UTF-8"?> <a> <b>my data</b> </a> 2008-10-01 14:21:44,563 INFO do something again I want... (3 Replies)
Discussion started by: csmklee
3 Replies

4. Shell Programming and Scripting

remove extra spaces between fields

Hi, I have a source file as mentioned below: I want to remove all the extra spaces between the fields. a b--------|sa df-------|3232---|3 sf sa------|afs sdf-----|43-----|33 a b c------|adfsa dsf---|23-32|23 *Here '-' idicates spaces Now, I want output as below: a b|sa df|3232|3... (7 Replies)
Discussion started by: srilaxmi
7 Replies

5. Shell Programming and Scripting

How to remove extra spaces from a string??

Hi, I have a string like this and i want to remove extra spaces that exists between the words. Here is the sentence. $string="The small DNA genome of hepadnaviruses is replicated by reverse transcription via an RNA intermediate. This RNA "pregenome" contains ... (2 Replies)
Discussion started by: vanitham
2 Replies

6. Shell Programming and Scripting

Remove of extra spaces from the trailing

HI, I need the help from the experts like I have created one file with text like: a b c d e f g h i j k l So my question is that i have to write the script in which like in the first sentence it will take only one space after d and remove all the extra space in the end.I dont... (8 Replies)
Discussion started by: bhanudhingra
8 Replies

7. Shell Programming and Scripting

Remove line breaks after a match

I need to remove all line breaks in a document after a match, until there is a blank line. Example below, after the match "THE GREEN TABLE" remove line breaks until a blank line. Then, after the match "THE BLUE TABLE" do the same. Before: THE GREEN TABLE Lorem ipsum dolor sit amet,... (14 Replies)
Discussion started by: dockline
14 Replies

8. Shell Programming and Scripting

Delete line breaks and extra spaces between patterns

Hi, if in between strings "<section" and "</section>" across multiple lines there occurs the string "ole-present", delete all line breaks and replace any tabs or multiple spaces with a single space. Looking for an AWK or SED solution. Thank you. <section ... status = "ole-present" ...... (2 Replies)
Discussion started by: pioavi
2 Replies

9. UNIX Desktop Questions & Answers

To remove the extra spaces at the end of each line in a file

I have a file of about 10k records and eace line is having an extra space of 5 byte at the end.. Iwant to remove the extra spaces at the end of each line.. Can someone please help me out.. I tried using sed command and its not working... can someone please help me out. (3 Replies)
Discussion started by: rammohan
3 Replies

10. Shell Programming and Scripting

Remove single-line breaks only in document

Regarding copy/pasted text of copyright-free book from archive.org (link below), in attempt to expand single-line-break paragraph text (not section headings or paragraph breaks) to wider right margin, Justify or Wrap in LIbreOffice is not working, and Find/Replace the paragraph mark ($) wraps all... (2 Replies)
Discussion started by: p1ne
2 Replies
TEXT2PS(L)																TEXT2PS(L)

NAME
text2ps - convert text files to PostScript SYNOPSIS
text2ps [ options ] [ files ] DESCRIPTION
Text2ps reads the input files (standard input if none are specified) and produces PostScript code which, when fed to a PostScript printer, will print the files. With text2ps it is possible to select any font, point size and number of columns. Options and files can be inter- mixed on the command line. Options are effective for all following files until they are overridden. Options Here follows a list of options that text2ps recognizes. Most numeric arguments are significant to one decimal place. Options are evalu- ated from left to right. Later options override earlier ones. -# n Print n copies of each page. (Default 1.) -c n Print in n columns. (Default 1.) -f font Print using font font. (Default Courier.) -p n Print with point size n. (Default 9.) -v n Use a vertical spacing of n points. If the vertical spacing is set to 0, the spacing will be 1.2 times the point size. (Default 0.) -l n Print n lines per column. When the line count is 0, print as many lines as will fit. (Default 0.) -r [p|l] Set the orientation to either portrait mode (p) or landscape mode (l). (Default p.) -b [+|-] Set page break mode. An argument + will force new files to be always printed on a new page (this is the default). After - new files will be put on the same page if there are still empty columns and the number of columns, the orientation or the number of copies didn't change. New files always start new columns. (Default -.) -mt n The top margin is n points. (Default 63.) -mb n The bottom margin is n points. (Default 63.) -ml n The left margin is n points. (Default 59.) -mr n The right margin is n points. (Default 59.) -mg n The inter-column gap is n points. (Default 25.) -t [+|-] If the argument is + the name of the file being printed will be printed on each page. If the argument is - the file name will not be printed. -t + implies -b +. -T text Print text as title on each page. This implies -t - and -b +. This option can be switched off by specifying -t - or -t +. (Default no title.) -F font Set the title font to font. (Default Helvetica.) -P n Set the title point size to n. (Default 12.) -B n Draw borders around each page. The number n specifies how to draw borders. N can have any of the following values or-ed in: 1 Draw a line along the left of the page. 2 Draw a line along the bottom of the page. 4 Draw a line along the right of the page. 8 Draw a line along the top of the page. 16 Draw a line between columns. This line does not connect to the lines along the top or bottom. 32 Draw a connecting line between the line between columns and the line along the top. 64 Draw a connecting line between the line between columns and the line along the bottom. When n is 0, no border lines are drawn. (Default no bordering lines.) -w n Tab stops are set every n spaces. Set the width of the TAB character. (Default 8.) -1 Sets up options to print in one column in portrait mode with the Courier font, so that you get 66 lines on a page. Equivalent to specifying the options -c 1 -f Courier -p 9 -v 0 -r p -l 0 -mt 63 -mb 63 -ml 59 -mr 59. This is the default. -2 Sets up options to print in two columns in landscape mode with the Courier font, so that you get two 66-line columns on a page. Equivalent to specifying the options -c 2 -f Courier -p 6 -v 0 -r l -l 0 -mt 63 -mb 63 -ml 59 -mr 59 -mg 25. Together with the -1 option, this is probably the most useful option. The name - means standard input. BUGS
Too many options. There is no way to specify where the title will be placed. If the font being used is not a constant width font and there are other characters than just tabs and spaces in front of a tab, the next character may not align properly. TEXT2PS(L)
All times are GMT -4. The time now is 06:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy