Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Using sed to remove spaces from middle of the line Post 302904373 by friedmi on Tuesday 3rd of June 2014 05:18:40 PM
Old 06-03-2014
Thank you, Don for prompt reply.
These are my examples.

Original line:
Code:
<td width=251 colspan=9 rowspan=22> <font size=2 face="courier"><tt><style>{font:7pt Courier  New;color:#000000}</style><a  href="/webaccess/AIntRez.cgi?ser ver=rsrv&report=%2Fdev%2Fypa%2Fhome%2Fentk ppa%2FTSTREP%2Freports%2FGET_TRANS ACTION_2000.rep&desformat=pdf&bat ch=yes&destype=file&p_date_time=200 807091331278990&p_batch_seqno=1&p_t ransaction_seqno=2&P_SESSION_ID=999999&P_ START_LINE=&P_END_LINE="  target="main">07/09/2008 13:31</a></tt></font><br></td>

Expected result:
Code:
<td width=251 colspan=9 rowspan=22> <font size=2 face="courier"><tt><style>{font:7pt Courier  New;color:#000000}</style><a href="/webaccess/AIntRez.cgi?server=rsrv&report=%2Fdev%2Fypa%2Fhome%2Fentkppa%2FTSTREP%2Freports%2FGET_TRANSACTION_2000.rep&desformat=pdf&batch=yes&destype=file&p_date_time=200807091331278990&p_batch_seqno=1&p_transaction_seqno=2&P_SESSION_ID=999999&P_START_LINE=&P_END_LINE=" target="main">07/09/2008 13:31</a></tt></font><br></td>

Original line:
Code:
<td width=183 colspan=10 rowspan=32> <font size=2 face="courier"><b><tt><style>{font:9pt Courier  New;color:#000000}</style ><a  href="/webaccess/AIntR ez.cgi?server=rsrv&rep ort=%2Fdev%2Fypa%2Fhome%2 Fentkppa%2FTSTREP%2Frepo rts%2FORDER_DETAIL_2000 .rep&desformat=pdf&batch= yes&destype=file&p_direct ory_number=000001&p_client _number =7500&p_dir_ver_stat=CURR ENT&p_req_mailbox_name=TS TUSER" target="main">  Current Order </a></tt></b></font><br></td>

Expected result:
Code:
<td width=183 colspan=10 rowspan=32> <font size=2 face="courier"><b><tt><style>{font:9pt Courier  New;color:#000000}</style ><a href="/webaccess/AIntRez.cgi?server=rsrv&report=%2Fdev%2Fypa%2Fhome%2Fentkppa%2FTSTREP%2Freports%2FORDER_DETAIL_2000.rep&desformat=pdf&batch=yes&destype=file&p_directory_number=000001&p_client_number=7500&p_dir_ver_stat=CURRENT&p_req_mailbox_name=TSTUSER" target="main">  Current Order </a></tt></b></font><br></td>

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to remove spaces in a string using sed.

Hello, I have the following to remove spaces from beginning and end of a string. infile=`echo "$infilename" | sed 's/^ *//;s/ *$//` How do I modify the above code to remove spaces from beginning, end and in the middle of the string also. ex: ... (4 Replies)
Discussion started by: radhika
4 Replies

2. Shell Programming and Scripting

How to 'sed' the middle line?

Hi, If I have 90 lines and I want to print the 45th line, is there a quick sed command for this? thx. (7 Replies)
Discussion started by: g_jumpin
7 Replies

3. Shell Programming and Scripting

remove leading spaces from a line

Hi friends I need some help, I have a file which looks as follows TEMP 014637065 014637065 517502 517502 RTE 517502 517502 RTE AWATER_TEST 12325 23563 588323 2323 5656 32385 23235635 ANOTHER_TEST 12 5433 FTHH 5653 833 TEST 123 123 3235 5353 353 53 35 353 535 3 YTERS GJK JKLS ... (6 Replies)
Discussion started by: lijojoseph
6 Replies

4. 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

5. Shell Programming and Scripting

sed over writes my original file (using sed to remove leading spaces)

Hello and thx for reading this I'm using sed to remove only the leading spaces in a file bash-280R# cat foofile some text some text some text some text some text bash-280R# bash-280R# sed 's/^ *//' foofile > foofile.use bash-280R# cat foofile.use some text some text some text... (6 Replies)
Discussion started by: laser
6 Replies

6. Shell Programming and Scripting

How to remove spaces using awk,sed,perl?

Input: 3456 565 656 878 235 8 4 8787 3 7 35 878 Expected output: 3456 565 656 878 235 8 4 8787 3 7 35 878 How can i do this with awk,sed and perl? (10 Replies)
Discussion started by: cola
10 Replies

7. Shell Programming and Scripting

tr and sed remove spaces. how to stop this?

if the answer is obvious, sorry, I'm new here. anyway, I'm using tr to encrypt with rot-13: echo `cat $script | tr 'a-zA-Z' 'n-za-mN-ZA-M'` > $script it works, but it removes any consecutive spaces so that there is just one space between words. I've had this problem before while using sed to... (5 Replies)
Discussion started by: Trichopterus
5 Replies

8. Shell Programming and Scripting

sed remove newlines and spaces

Hi all, i am getting count from oracle 11g by spooling it to a file. Now there are some newline characters and blank spaces i need to remove these. pl provide me a awk/sed solution. the spooled file is attached. i tried this.. but not getting req o/p (6 Replies)
Discussion started by: rishav
6 Replies

9. Shell Programming and Scripting

How to remove spaces on a line?

Hi, suppose I have the following data: albert music=top40 age=20 bob music=punk rock age=25 candy music=r n b age=22 dave music=mozart or bach only age=30 I want to extract and manipulate the music column but it's got spaces in it. How can I substitute the space with an underscore... (2 Replies)
Discussion started by: almonds
2 Replies

10. Shell Programming and Scripting

Can't remove spaces with sed when calling it from sh -c

The following command works echo "some text with spaces" | sh -c 'sed -e 's/t//g''But this doesn't and should echo "some text with spaces" | sh -c 'sed -e 's/ //g''Any ideas? (3 Replies)
Discussion started by: Tribe
3 Replies
uniq(1) 						      General Commands Manual							   uniq(1)

Name
       uniq - report repeated lines in a file

Syntax
       uniq [-udc[+n][-n]] [input[output]]

Description
       The  command  reads  the  input	file comparing adjacent lines.	In the normal case, the second and succeeding copies of repeated lines are
       removed; the remainder is written on the output file.  Note that repeated lines must be adjacent in order to be found.  For further  infor-
       mation, see

Options
       The n arguments specify skipping an initial portion of each line in the comparison:

       -n Skips specified number of fields.  A field is defined as a string of non-space, non-tab characters separated by tabs and spaces from its
	  neighbors.

       +n Skips specified number of characters in addition to fields.  Fields are skipped before characters.

       -c Displays number of repetitions, if any, for each line.

       -d Displays only lines that were repeated.

       -u Displays only unique (nonrepeated) lines.

       If the -u flag is used, just the lines that are not repeated in the original file are output.  The -d option specifies  that  one  copy	of
       just the repeated lines is to be written.  The normal mode output is the union of the -u and -d mode outputs.

       The  -c option supersedes -u and -d and generates an output report in default style but with each line preceded by a count of the number of
       times it occurred.

See Also
       comm(1), sort(1)

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