separate old entries


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting separate old entries
# 1  
Old 08-16-2012
separate old entries

Hi I have a file
Code:
Stomach
qwe
wer
qwew
Liver
sdfjk
shdf
jkasfhd

I want expected out shuld be in such a way that bold letters shuld comein front of non bold letter
Code:
qwe              Stomach
wer              Stomach
qwew          Stomach
sdfjk            Liver
shdf           Liver
jkasfhd        Liver

# 2  
Old 08-16-2012
Show your efforts please. Any answers before that will be moderated.
This User Gave Thanks to zaxxon For This Post:
# 3  
Old 08-16-2012
bold string starts with capital char
# 4  
Old 08-16-2012
actually all bold strings are capital

Code:
Stomach is actually STOMACH
Liver is actually LIVER

I didnt realise it in my input that I m writing only first char as capital but in input all bold characters are capital
# 5  
Old 08-16-2012
@raj_saini20:

Quote:
Any answers before that will be moderated.
# 6  
Old 08-16-2012
Hi Raj,

I tried this

Code:
awk '($1 ~ /[A-Z]/){x=$1;next}{print $1,x}' filename


but it's not working properly it shows just three names in output which does nto contain any information.

I have a long list of file like this

Code:
STOMATOLOGICAL PREPARATIONS
Doxycycline 
Clotrimazole 
Triamcinolone 
Epinephrine 
Amphotericin B 
Hydrocortisone 
DRUGS FOR ACID RELATED DISORDERS
Pantoprazole 
Omeprazole 
Sucralfate 
Lansoprazole 
Cimetidine 
Nizatidine



And, I need the output like this

Code:
Doxycycline    STOMATOLOGICAL PREPARATIONS
Clotrimazole     STOMATOLOGICAL PREPARATIONS
Triamcinolone    STOMATOLOGICAL PREPARATIONS
Epinephrine        STOMATOLOGICAL PREPARATIONS
Amphotericin B    STOMATOLOGICAL PREPARATIONS
Hydrocortisone      STOMATOLOGICAL PREPARATIONS

Pantoprazole          DRUGS FOR ACID RELATED DISORDERS
Omeprazole            DRUGS FOR ACID RELATED DISORDERS
Sucralfate              DRUGS FOR ACID RELATED DISORDERS
Lansoprazole           DRUGS FOR ACID RELATED DISORDERS
Cimetidine                DRUGS FOR ACID RELATED DISORDERS
Nizatidine                DRUGS FOR ACID RELATED DISORDERS

# 7  
Old 08-16-2012
Code:
awk '{y=$0;gsub(" ","",y);if(y ~ /^[A-Z]*$/){x=$0;next};print $0,x}' filename

output is
Code:
Doxycycline  STOMATOLOGICAL PREPARATIONS
Clotrimazole  STOMATOLOGICAL PREPARATIONS
Triamcinolone  STOMATOLOGICAL PREPARATIONS
Epinephrine  STOMATOLOGICAL PREPARATIONS
Amphotericin B  STOMATOLOGICAL PREPARATIONS
Hydrocortisone  STOMATOLOGICAL PREPARATIONS
Pantoprazole  DRUGS FOR ACID RELATED DISORDERS
Omeprazole  DRUGS FOR ACID RELATED DISORDERS
Sucralfate  DRUGS FOR ACID RELATED DISORDERS
Lansoprazole  DRUGS FOR ACID RELATED DISORDERS
Cimetidine  DRUGS FOR ACID RELATED DISORDERS
Nizatidine DRUGS FOR ACID RELATED DISORDERS

is that ok
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print the overlapping entries in 2 files to separate file

I have two files that contain overlapping positions. i want to put them together each overlapping entries in both files in to a new file (the entries of first file first and the entries of second file next) followed by blank line then next overlapping entries and so on. input1 chr1 22 ... (10 Replies)
Discussion started by: raj_k
10 Replies

2. Shell Programming and Scripting

Match first column and separate entries

Hi I have 2 big files containing following information: file 1 12345 345634 217341 87234693 8236493 file 2: 12345 1237 (6 Replies)
Discussion started by: kaav06
6 Replies

3. Shell Programming and Scripting

Separate Entries after comma

Hi All I need help to separate entries after commas in my I have 2 columns in my file like this Ramush, Shyam, Mohan First Ram, Mohan, Kaavya Second, Fourth Kavi, Ram, Shaym, Mohan Third I ahve to separate entries after comma in a separate row... (9 Replies)
Discussion started by: kareena
9 Replies

4. Shell Programming and Scripting

Remove bracket part entires and separate entries after comma

Hi all This time my input conatin 3 columns: ERCC1 (PA155) Platinum compounds (PA164713176) Allele A is not associated with response to Platinum compounds in women with Ovarian Neoplasms as compared to allele C . CES1 (PA107) methylphenidate (PA450464) Genotype CT is not... (4 Replies)
Discussion started by: Priyanka Chopra
4 Replies

5. Shell Programming and Scripting

Separate two numbers

I would like to separate number by space so that 121231212 222111212 would be 1 2 1 2 3 1 2 1 2 2 2 2 1 1 1 2 1 2 Thanks! (2 Replies)
Discussion started by: johnkim0806
2 Replies

6. Shell Programming and Scripting

Count and separate entries with N/A mentioned in front

Hi all, I have afile with following data I want to separate, count the entries with N/A in front of it so I will have all the entries with N/A in front seprate file . so output shuld be (7 Replies)
Discussion started by: manigrover
7 Replies

7. Shell Programming and Scripting

Separate certain entries from a very big file

Hello I have to separate certain entries from a Big file with so many drugs and description I want to seaprate only Drug name which is mentioned as #BEGIN_DRUGCARD DB00001(means first drug description initiated) ..same way DB00002...and so on and in description I have to separate #... (3 Replies)
Discussion started by: manigrover
3 Replies

8. Shell Programming and Scripting

Cant separate variables

Hey guys, new problem....im not being able to seperate variables. the code runs like this... OPTIONS=$(awk '{print $2}' /etc/fstab} a=$(zenity --list --text "Mount points selection" --radiolist --column "choice" --column "mountpt" FALSE $OPTIONS); echo $a Note: the result i get is that... (2 Replies)
Discussion started by: dplate07
2 Replies

9. Shell Programming and Scripting

Separate string

i am a biginner of shell scripting.please help me how can i seperate a string in two parts.eg.user given sting is"oi2ehello".i want to make 2 string string1=oi2e and string2=hello (3 Replies)
Discussion started by: arghya_owen
3 Replies

10. Shell Programming and Scripting

separate out the column

I know "awk -F:" will separate out the column by ":" , now if I what to separate out the column by space also , what can I do ? for example : #ps -ef |grep telnet root 10159 702 0 15:45 ? 00:00:00 in.telnetd: 192.168.0.1 how to separate out the column so that the column as below, ... (6 Replies)
Discussion started by: ust
6 Replies
Login or Register to Ask a Question