Cell arrangement


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cell arrangement
# 1  
Old 08-18-2006
Network Cell arrangement

I have a data file with hundreds of lines: I want to place a YES right below the line that say mydata....can someone please help! on the left is my the original data on the right the data format need to be:

left > Right

mydata > mydata
yes > yesno > no
mydata > mydata
no > yesyes > no
mydata > mydata
no > yesyes > no
mydata > mydata
yes > yesno > no
# 2  
Old 08-18-2006
Data

mydata > mydata
yes > yes
no > no
mydata > mydata
no > yes
yes > no
mydata > mydata
no > yes
yes > no
mydata > mydata
yes > yes
no > no
# 3  
Old 08-18-2006
Your request is a little confusing but if you want the second output you can use this hack:
Code:
nawk '
    !/^[(yes|no)]/ {print}
    /^[(yes|no)]/ {
        sub (/yesno/, "yes\nno")
        sub (/yesyes/, "yes\nyes")
        sub (/noyes/, "no\nyes")
        sub (/nono/, "no\nno")
        print
    }' file.txt

# 4  
Old 08-18-2006
Data

Sorry for the confusion! This is what I am ask ing for:

Data file contain the following information (1000 line or more)

mydata1
abc YES
dcf NO
mydata2
dcf NO
abc YES
mydata3
dcf NO
abc YES

I need it to have the following format:

mydata1
abc YES
dcf NO
mydata2
abc YES
dcf NO
mydata3
abc YES
dcf NO

Please let me know if you can help!
# 5  
Old 08-20-2006
see if this works

Assuming there are 2 lines after every occurence of pattern.
Code:
awk '/mydata/ {orig=$0; getline;one=$0;getline;two=$0; if( one ~ "YES") {printf("%s\n%s\n%s\n",orig,one,two)} else {printf("%s\n%s\n%s\n",orig,two,one)} }' fname

# 6  
Old 08-21-2006
Data This command is not working

and here are the message I got:

awk: syntax error near line 1
awk: illegal statement near line 1
awk: bailing out near line 1


Thanks!
# 7  
Old 08-21-2006
it works for me

I use HP-UX B.11.11 and the above code works. May be it could some quotes or some other character that is causing the issue.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Retreive data with arrangement

Hi all I have following part of a big file TTDS00002 Synonyms M1 receptor TTDS00002 Disease Alzheimer's disease TTDS00002 Disease Bronchospasm (histamine induced) TTDS00002 Disease Cognitive deficits TTDS00002 Disease Schizophrenia TTDS00002 Function The muscarinic acetylcholine... (2 Replies)
Discussion started by: kareena
2 Replies

2. UNIX for Advanced & Expert Users

Data re-arrangement

Hi I have a huge problem to solve ASAP. Can someone please help!!! My format is arranged in this format: It has three columns. LOGIN ALIAS REC_ID A BB1 0 A ... (1 Reply)
Discussion started by: Mapilo
1 Replies

3. Shell Programming and Scripting

directories and file arrangement in bash

im trying to write a script that will put files with different extensions into their specified directories In the directory are files of various types, i want to arrange the files on individual directories under their type. There are three distinct types of files: 1) Text documents - files with... (2 Replies)
Discussion started by: elginmulizwa
2 Replies

4. Shell Programming and Scripting

Help to data re-arrangement problem

Input file <data id>="1">\ </data>\ <data id>="2">\ </data>\ <code>="1" target="2">\ </code>\ <data id>="1">\ </data>\ <data id>="2">\ </data>\ <code>="1" target="2">\ </code>\ <data id>="1">\ </data>\ <data id>="2">\ </data>\ <code>="1" target="2">\ </code>\ (2 Replies)
Discussion started by: cpp_beginner
2 Replies

5. Shell Programming and Scripting

Re-arrangement of data

Dear Frineds, I have a flat file as follows ABCD ABDCWQE POIERAS ADSGASGFG GHJKFHD XBDFGHFGDH POIU IJPFG AFGJFPGOU A;DGUPGU SFSDFDSDFHDSF SDFGHSFDH I want this column to be converted into row like follows ABCD, ABDCWQE, POIERAS, ADSGASGFG, GHJKFHD, XBDFGHFGDH (6 Replies)
Discussion started by: anushree.a
6 Replies

6. Shell Programming and Scripting

sorting/arrangement problem

Hi, I have the following 'sorting' problem. Given the input file: a:b:c:12:x:k s:m:d:8:z:m a:b:c:1:x:k p:q:r:23:y:m a:b:c:3:x:k p:q:r:1:y:m the output I expect is: a:b:c:1:x:k p:q:r:1:y:m s:m:d:8:z:m What happened here is I grouped together lines having the same values for... (7 Replies)
Discussion started by: Abhishek Ghose
7 Replies

7. UNIX for Dummies Questions & Answers

Help on file arrangement

Can anyone help me on this. I have a file that looks like this: color red green blue color pink yellow number one two gender male gender female The output would look like this: color red green blue pink yellow number one two gender male female I have over 5000 rows and i dont want... (5 Replies)
Discussion started by: kharen11
5 Replies

8. UNIX for Dummies Questions & Answers

Data arrangement

10 2 1 2 3 4 5 6 7 8 20 3 2 1 3 2 9 8 2 1 Need the data to be arranged: 10 2 1 5 2 6 3 7 4 8 20 3 2 1 1 2 3 8 2 9 please help! (6 Replies)
Discussion started by: bobo
6 Replies

9. UNIX for Dummies Questions & Answers

Data arrangement

I have these following data: Home Tom Member List 100 Yes 200 No Home Tom Member List 1 No 2 Yes Home Tome Member List 3 No 400 Yes I want my data to be consistants like this: (4 Replies)
Discussion started by: bobo
4 Replies

10. UNIX for Dummies Questions & Answers

Text file arrangement

Dear UNIX experts: Hi, I have a text file which the contents are arranged vertically down, line by line. How do use a loop (I think) to make it arrange in vertical arrangement with a tab delimitated and write to a new file? Eg: of source file Hello World Good-day Thanks Welcome The... (8 Replies)
Discussion started by: merry susana
8 Replies
Login or Register to Ask a Question