Text manipulation with gawk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Text manipulation with gawk
# 15  
Old 12-15-2010
Ok. Did not know this.

BTW, your solution does not work, if there are special charcters between the [ and ]. Any idea why?

Robert
# 16  
Old 12-15-2010
Please post an example - a representative sample of your real data.
# 17  
Old 12-15-2010
Quote:
Originally Posted by radoulov
Please post an example - a representative sample of your real data.
Code:
lorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsumlorem ipsum 
lorem ipsumlorem ipsum 
lorem ipsum 
 
lorem ipsumlorem ipsum 
 
 
[Stefan Franz Schmidt] Stefan Franz Schmidt 
stellv. Geschäftsführer 
IBM USA 
 
    * lorem ipsum 
    * lorem ipsum 
    * lorem ipsum 
 
[Hansi Möller] Hansi Möller   mlorem ipsum  
Leiter HR 
Google USA 
 
    * lorem ipsum 
    * lorem ipsum 
    * lorem ipsum 
 
[Stefan Müller] Stefan Müller 
Leiter Einkauf 
Google Germany 
 
    * lorem ipsum 
    * lorem ipsum 
    * lorem ipsum

and so on ...

Desired Result:
Code:
Stefan Franz Schmidt; stellv. Geschäftsführer; IBM USA
Hansi Möller;Leiter HR; Google USA
Stefan Müller;Leiter Einkauf; Google Germany

Current result:
Code:
Stefan Franz Schmidt;stellv. Geschäftsführer ;IBM USA 
[Hansi Möller] Hansi Möller ;Leiter HR ;Google USA 
[Stefan Müller] Stefan Müller ;Leiter Einkauf ;Google Germany

Thanks!

Robert

Last edited by radoulov; 12-15-2010 at 10:28 AM.. Reason: Code tags, please!
# 18  
Old 12-15-2010
Hm, I get the desired result. What's your operating system and what's the version of awk you're using?
# 19  
Old 12-15-2010
Quote:
Originally Posted by radoulov
Hm, I get the desired result. What's your operating system and what's the version of awk you're using?
Latest version of Ubuntu.

Found the error. Was a coding problem. Since I generated the file on a Windows machine, the line ending was different. Now, it works 100%.

Once more!

THANK YOU VERY MUCH!!!!

Best
Robert
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Text Manipulation Help

Hello again unix.com, I have a text file in this format (line-by-line): hostname id password hostname id password hostname id password hostname id password I want it to become: hostname id password hostname id password hostname id password hostname id password (4 Replies)
Discussion started by: galford
4 Replies

2. Shell Programming and Scripting

Gawk - Text replace - need help

Hello, i am a working student and have to build a patch setup. I have to replace 2 lines in a .txt file. Can someone help me please. Now: wrapper.java.mainclass=org.tanukisoftware.wrapper. WrapperSimpleApp wrapper.java.classpath.2=../../jdk/lib/tools.jar replace with:... (12 Replies)
Discussion started by: Baefisch
12 Replies

3. Shell Programming and Scripting

Text manipulation help

Hello Unix.com, How can i generate links like this: i got http://upload.com/1/1.txt and i need to generate links from http://upload.com/1/1.txt to http://upload.com/1000/1000.txt Thanks in advance, Galford D. Weller (4 Replies)
Discussion started by: galford
4 Replies

4. Shell Programming and Scripting

gawk script to search and replace text in a flat file

Hi I am new to unix and newbie to this forum. I need help in writing a gawk script that search and replace particular text in a flat file. Input file text : ZIDE_CONTROL000 100000000003869920900000300000001ISYNC 000002225489 0000000002232122 20120321 16:40:53 ZIDE_RECORD000... (5 Replies)
Discussion started by: gkausmel
5 Replies

5. UNIX for Dummies Questions & Answers

text manipulation help

Hello again unix.com How can I extract from a large file in format: steve@aol.com steve hawkins Location of this member is bla bla bla sun@hotmail.com Sun Ying This member is using browser bla bla bla to another text in format: steve@aol.com steve hawkins sun@hotmail.com sun ying ... (5 Replies)
Discussion started by: galford
5 Replies

6. Shell Programming and Scripting

Text Manipulation Help

Hello unix.com people! How can I modify a text in format: A:B:C A:B:C A:B:C into C/A/B C/A/B C/A/B Note: Text is line by line and "C", "B", "A" fields are different each row. Thanks in advance. (7 Replies)
Discussion started by: galford
7 Replies

7. Shell Programming and Scripting

[HELP] Text manipulation... [HELP]

I need to know how can I remove all word after comma on each line. Like: jjkj,iiuiui,ijlkjkij,ookoo kijljlj,jhhkj,ijijkijkj,oijkijj kjkljlkj,kjkjlkjlkj,opok,okop to jjkj, kijljlj, ... (5 Replies)
Discussion started by: slutb3
5 Replies

8. UNIX for Dummies Questions & Answers

JOINING MULTIPLE LINES IN A TEXT FILE USING GAWK

sir... am having a data file of customer master., containing some important fields as a set one line after another., what i want is to have one set of these fields(rows) one after another in line.........then the second set... and so on... till the last set completed. I WANT THE DATA... (0 Replies)
Discussion started by: KANNI786
0 Replies

9. UNIX for Dummies Questions & Answers

Joining lines of a text file using GAWK

sir... am having a data file of customer master., containing some important fields as a set one line after another., what i want is to have one set of these fields(rows) one after another in line.........then the second set... and so on... till the last set completed. ... (0 Replies)
Discussion started by: KANNI786
0 Replies

10. Shell Programming and Scripting

Text Manipulation.

Hi I have only ever used awk and sed for basic requirements up until now. I have had to break a log down for multiple purposes. Using awk, sed and a date script. I am left with this: (message id, time of msg attempt, message id, domain name, time of msg completion) ... (4 Replies)
Discussion started by: Icepick
4 Replies
Login or Register to Ask a Question