How to seperate two lines that are joined?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to seperate two lines that are joined?
# 1  
Old 07-28-2012
How to seperate two lines that are joined?

i have something like this
Code:
abc 123 3234 1234 * qqoiki *  abc 4533 34 1234 * lloiki *

i want to make it two lines i,e.,
Code:
abc 123 3234 1234 * qqoiki * 
abc 4533 34 1234 * lloiki *

how to do that ?
# 2  
Old 07-28-2012
Try:
Code:
perl -pe 's/\*[^*]+\*\s+/$&\n/' file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 07-28-2012
Not sure on what you want to split the line - nth field, second occurrence of first field, nth character, ...?
# 4  
Old 07-28-2012
its based on second occurrence of first field
# 5  
Old 07-28-2012
With sed:
Code:
sed '/^$/d
s/* */*\
/2
P
D' inputfile

# 6  
Old 07-28-2012
using mawk 1.3.3 under linux, given your data are in file "test", this would do:
Code:
awk 'split ($0, A, $1) {printf "%s%s\n%s%s\n", $1, A[2], $1, A[3]}' test

resulting in:
Code:
abc 123 3234 1234 * qqoiki *  
abc 4533 34 1234 * lloiki *

# 7  
Old 07-28-2012
Code:
sed 's/\([^ ]*\)\(.*\)\(\1.*\)/\1\2\
\3/' infile

Code:
awk 'gsub($1,RS $1) && sub(RS,x)' infile


Last edited by Scrutinizer; 07-28-2012 at 08:17 AM..
This User Gave Thanks to Scrutinizer For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Seperate columns according to delimiters

Hi all I need your help to separate colomns based on "-" delimiter for a very big file 30 millions rows I have a colmun looking like this : clomun 1 1-100000989-A_ATC 1-10000179-AAAAA 1-100002154-TGTTA 1-100002155-GTTAG 1-100002443 1-100002490 1-100002619 I need to separte in three... (5 Replies)
Discussion started by: biopsy
5 Replies

2. High Performance Computing

Huge Files to be Joined on Ux instead of ORACLE

we have one file (11 Million) line that is being matched with (10 Billion) line. the proof of concept we are trying , is to join them on Unix : All files are delimited and they have composite keys.. could unix be faster than Oracle in This regards.. Please advice (1 Reply)
Discussion started by: magedfawzy
1 Replies

3. Programming

USing two seperate programmes on same FIFO

hi this is a problem statement i have tried real hard but could not come up with a satisfactory program can someone help you are to create a pair of programs that do the following in this order: 1 one of the program creates a FIFO which another program should be able to write into 2 the... (2 Replies)
Discussion started by: puneetparnani
2 Replies

4. Shell Programming and Scripting

split a sentence and seperate into two lines

Hi, I have a string as str="route net,-hopcount,1,255.255.255.0,10.230.20.111,10.230.20.234 Route True route net,-hopcount,0,-netmask,255.255.248.0,0,10.230.23.254 Route True" I need to split this string into two lines as route net,-hopcount,1,255.255.255.0,10.230.20.111,10.230.20.234... (4 Replies)
Discussion started by: chaitanyapn
4 Replies

5. Shell Programming and Scripting

Set lines of in a file to seperate vars

In a bash script, I'm looking for a way to set each matching line of a file into its own variable, or variable array. As an example, i have a crontab file with several entries: 00 23 * * * /usr/local/bin/msqlupdate -all 00 11 * * * /usr/local/bin/msqlupdate -inc 00 03 * * *... (2 Replies)
Discussion started by: lochraven
2 Replies

6. Shell Programming and Scripting

how to awk a data from seperate lines

Hi guys, i have a problem which im hoping you will be able to help me with. I have follwing output :- ------------------------------------------------------------------------------- NSTEP = 407000 TIME(PS) = 43059.000 TEMP(K) = 288.46 PRESS = 0.0 Etot = -2077.4322 ... (2 Replies)
Discussion started by: Mish_99
2 Replies

7. Shell Programming and Scripting

how to seperate space in a string

Dear Members, I have string like this string1="file2.txt file4.txt kittu.txt file1.txt" in this i need to cut spaces and take each one has one file output should be --------- fileslist:4 file2.txt file4.txt kittu.txt file1.txt is it possible, please tell me how it possible ... (5 Replies)
Discussion started by: kittusri9
5 Replies

8. Shell Programming and Scripting

Script needs to be modified - Each 5 Rows to be joined in single line with comma (,)

Hi All, I'm using the following script to produce a result: #!/bin/sh awk ' $0 ~ /\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+Interface\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+/ { match_str="YES"; line_cnt=0; next; } { if((line_cnt < 5) && ( match_str=="YES")) { print $0; line_cnt += 1; } else... (0 Replies)
Discussion started by: ntgobinath
0 Replies

9. Shell Programming and Scripting

Need help to seperate data

Hello ALL, I really need help to grep data and store in particular format. I am struggling to write that script .Please help me to solve this problem otherwise i will loose my job... I have to compare 2 files and generate the staticts of the data. First file product.dat contains 2 column . ... (4 Replies)
Discussion started by: getdpg
4 Replies

10. Shell Programming and Scripting

row seperate

i have this sample data: test01 --- abc-01 name1 abc-02 name2 abc-03 name3 test02 --- abc-20 name4 abc-21 name5 test03 --- abc-22 name6 abc-23 name7 i want to generate a file... (13 Replies)
Discussion started by: inquirer
13 Replies
Login or Register to Ask a Question