how to remove mutilple enrty in a single line in unix


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to remove mutilple enrty in a single line in unix
# 1  
Old 02-26-2009
Question how to remove mutilple enrty in a single line in unix

Hi,
Below is a single line output.

subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,common,00000000 subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,01,baoc|notActive|notInduced,activeAndOperative,notActive,notActive,noneDesignated,0,notActive| 00|,notActive|00|,notActive|00|,notActive|00|30|,, subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,02,baoc|notActive|notInduced,notActive,notActive,notActive,noneDesignated,0,notActive|00|,notAc tive|00|,notActive|00|,notActive|00|30|,,


In which "01 02 03 04 05 00 00 00 00 07 00 05" get repeat 3 time in a line.
I need a output which should be like this:

subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,common,00000000 subsD,,hlr,01,baoc|notActive|notInduced,activeAndOperative,notActive,notActive,noneDesignated,0,notA ctive|00|,notActive|00|,notActive|00|,notActive|00|30|,, subsD,,hlr,02,baoc|notActive|notInduced,notActive,notActive,notActive,noneDesignated,0,notActive|00| ,notActive|00|,notActive|00|,notActive|00|30|,,

in a single line output.

Thanks for support.
# 2  
Old 02-26-2009
Assuming that it is always the same fields that have to be replaced:

Code:
awk -F"," '{sub(/.*/,"",$6); sub(/.*/,"",$21); print}' OFS="," infile
subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,common,00000000 subsD,,hlr,01,baoc|notActive|notInduced,activeAndOperative,notActive,notActive,noneDesignated,0,notActive| 00|,notActive|00|,notActive|00|,notActive|00|30|,, subsD,,hlr,02,baoc|notActive|notInduced,notActive,notActive,notActive,noneDesignated,0,notActive|00|,notAc tive|00|,notActive|00|,notActive|00|30|,,

# 3  
Old 02-26-2009
hi,

fields/column are not fixed,
given code will not work properly.
suggest else.

Thanks
# 4  
Old 02-26-2009
Do the strings at least always stand between
Code:
subsD,<your string>,hlr

or start with subsD or end with hlr?
Or is the string itself fixed?

Need more precise info.
# 5  
Old 02-26-2009
it starts with subsD,<String>,hlr.

its fixed pattern.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove single @ on line from file

Hi All, So I have to remove all the @hostnames from a file, the problem is, there are instances where @ is used for other things... For example: example text: @This is some text in between some at signs@ @This is some more text@ This is a line that will contain a username and his/her... (5 Replies)
Discussion started by: joeg1484
5 Replies

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

3. UNIX for Dummies Questions & Answers

Remove multi line and single line comments

Hi, I am trying to remove multi line and single line comments like examples below I have tried this pattern. it works fine for single line comments and multi line comments in a single line only. but this fails when the comments are extended in multiple lines as shown in the comment 2 of... (3 Replies)
Discussion started by: ahmedwaseem2000
3 Replies

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

5. UNIX for Advanced & Expert Users

unix command for terminal - view sequences as a single line?

Hello, I'm looking for some code that will list sequences of files as a single line. ie, sequences of files like this: filename.1.ext filename.2.ext filename.3.ext filename.4.ext filename.5.ext filename.6.ext filename.7.ext filename.8.ext filename.9.ext filename.10.ext would... (6 Replies)
Discussion started by: kentm
6 Replies

6. Shell Programming and Scripting

Single command for add 2 columns and remove 2 columns in unix/performance tuning

Hi all, I have created a script which adding two columns and removing two columns for all files. Filename: Cust_information_1200_201010.txt Source Data: "1","Cust information","123","106001","street","1-203 high street" "1","Cust information","124","105001","street","1-203 high street" ... (0 Replies)
Discussion started by: onesuri
0 Replies

7. Shell Programming and Scripting

Single/Multiple Line with Special characters - Find & Replace in Unix Script

Hi, I am creating a script to do a find and replace single/multiple lines in a file with any number of lines. I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE print $FIND gives Hi How r $u Rahul() Note:... (0 Replies)
Discussion started by: r_sarnayak
0 Replies

8. UNIX for Dummies Questions & Answers

run command Unix on a single line

Hi everybody.. I need to enter in bash mode and then run a command and this just in a single command line. I tried : "bash ^M| somecommand" but nothing.. How do I do to simulate the return button just right after the bash command ? Thanks.. (8 Replies)
Discussion started by: Riddick61
8 Replies

9. UNIX for Dummies Questions & Answers

Trying to remove single character from a line

Here is a sample code grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g' the input file has data as such 903-xxx-xxxxB 903-xxx-xxxxB It is a dialer file i want to remove the "B" any help thanks (5 Replies)
Discussion started by: Iz3k34l
5 Replies

10. Programming

remove single-line comment

Does anyone knows how to write a program to remove single-line comment in C program? that means it don't read anything behind // (3 Replies)
Discussion started by: Icy002
3 Replies
Login or Register to Ask a Question