formatting data to remove newline


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers formatting data to remove newline
# 1  
Old 02-24-2011
formatting data to remove newline

Hi All,

I have raw data in the format :-
--------------------------------------------------------------------
Code:
NUT070  
       3  ./opc.sh SQLSCRIPT &SID sysdate.sql 20120105
NUW004  
       3  ./opc.sh SQLSCRIPT &SID sab_supp.sql
UNUW032  
       3  ./opc.sh SQLSCRIPT &SID sab_unsupp.sql

---------------------------------------------------------------------

I want to remove the new line so that it becomes like this
--------------------------------------------------------------------
Code:
NUT070       3  ./opc.sh SQLSCRIPT &SID sysdate.sql 20120105
NUW004      3  ./opc.sh SQLSCRIPT &SID sab_supp.sql
UNUW032    3  ./opc.sh SQLSCRIPT &SID sab_unsupp.sql

---------------------------------------------------------------------
please advice

Thanks & regards,
Subhadeep
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 02-24-2011 at 10:15 AM.. Reason: code tags, please!
# 2  
Old 02-24-2011
Code:
 $ ruby -ne 'print $.%2==0 ?"#{$_}":"#{$_.chomp}"' file

# 3  
Old 02-24-2011
Code:
 # cat infile
NUT070
3 ./opc.sh SQLSCRIPT &SID sysdate.sql 20120105
NUW004
3 ./opc.sh SQLSCRIPT &SID sab_supp.sql
UNUW032
3 ./opc.sh SQLSCRIPT &SID sab_unsupp.sql

Code:
# sed 'N;s/\n/ /' infile
NUT070 3 ./opc.sh SQLSCRIPT &SID sysdate.sql 20120105
NUW004 3 ./opc.sh SQLSCRIPT &SID sab_supp.sql
UNUW032 3 ./opc.sh SQLSCRIPT &SID sab_unsupp.sql

Code:
# nawk 'ORS=(NR%2)?FS:RS' infile
NUT070 3 ./opc.sh SQLSCRIPT &SID sysdate.sql 20120105
NUW004 3 ./opc.sh SQLSCRIPT &SID sab_supp.sql
UNUW032 3 ./opc.sh SQLSCRIPT &SID sab_unsupp.sql


Last edited by ctsgnb; 02-24-2011 at 09:43 AM..
# 4  
Old 02-28-2011
thanks!!

Thank You Much !!!

Its working fine .....
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mail/mailx ignores newline formatting Problem.

I have a file hello.txt which i wish to send as a email body (not attachment). cat -ev hello.txt 1$ 2$ 3$ I use the following command to send the hello.txt as the email body. mailx -s "Alert" myteam@mycomp.com<hello.txt However, the email received has this in the email body 123... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. Shell Programming and Scripting

Remove last newline character..

Hi all.. I have a text file which looks like below: abcd efgh ijkl (blank space) I need to remove only the last (blank space) from the file. When I try wc -l the file name,the number of lines coming is 3 only, however blank space is there in the file. I have tried options like... (14 Replies)
Discussion started by: Sathya83aa
14 Replies

3. UNIX for Dummies Questions & Answers

Remove newline char from variable

I have a file ABC.DAT with 2 columns avaialble Data format : XYZ!$#$!120 XXZ!$#$!1000 YYZ!$#$!104 While running the following code : FILE_COUNTER=1; RECORD_CN_FILE_COUNT=$((`wc -l ABC.DAT| cut -f1 -d' '`)); while do FILE_NAME=`cat ABC.DAT.DAT| head -$FILE_COUNTER |tail -1 | awk -F... (1 Reply)
Discussion started by: Nikhil Gautam
1 Replies

4. Shell Programming and Scripting

Remove newline character between two delimiters

hi i am having delimited .dat file having content like below. test.dat(5 line of records) ====== PT2~Stag~Pt2 Stag Test. Updated~PT2 S T~Area~~UNCEF R20~~2012-05-24 ~2014-05-24~~ PT2~Stag y~Pt2 Stag Test. Updated~PT2 S T~Area~METR~~~2012-05-24~2014-05-24~~test PT2~Pt2 Stag Test~~PT2 S... (4 Replies)
Discussion started by: sushine11
4 Replies

5. Shell Programming and Scripting

remove ] followed by newline in bash

I need to remove ] followed by newline character to convert lines like: line1] line2 into: line1line2 (4 Replies)
Discussion started by: locoroco
4 Replies

6. UNIX for Dummies Questions & Answers

Remove newline & space

Can someone help me on this. I have a file that has a long line just like below. The long line keeps on being truncated to the next line (new line + space) for some reason. Basically, I just need to remove this problem. Hope somebody can help! Thanks! INPUT FILE: structuralObjectClass:... (4 Replies)
Discussion started by: Orbix
4 Replies

7. Shell Programming and Scripting

Remove newline character conditionally

Hi All, I have 5000 records like this Request_id|Type|Status|Priority|Ticket Submitted Date and Time|Actual Resolved Date and Time|Current Ticket Owner Group|Case final Ticket Owner Group|Customer Severity|Reported Symptom/Request|Component|Hot Topic|Reason for Missed SLA|Current Ticket... (2 Replies)
Discussion started by: j_53933
2 Replies

8. Shell Programming and Scripting

SED: how to remove newline after pattern?

Hi, I have the following XML not well-indented code: <hallo >this is a line </hallo> So I need to remove the newline. This syntax finds what I need to correct, but I don't know how to remove the newline after my pattern: sed 's/<.*$/&/' How can I subtract the newline after my... (1 Reply)
Discussion started by: nico.ben
1 Replies

9. Shell Programming and Scripting

how to remove all tabs and newline (\n)

how to remove all tabs and newline (\n) from the exicting file (2 Replies)
Discussion started by: pvr_satya
2 Replies

10. Shell Programming and Scripting

Formatting a text file based on newline and delimiter characters

Hi Everybody, I need some help on formatting the files coming into unix box on the fly. I get a file some thing like this in a single line. ISA^M00^M ^M00^M ^M14^M006929681900 ^M01^M095449419 ... (5 Replies)
Discussion started by: ntekupal
5 Replies
Login or Register to Ask a Question