How to remove all words from a matching word in a line?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to remove all words from a matching word in a line?
# 1  
Old 04-25-2010
How to remove all words from a matching word in a line?

Hi Guys, Smilie

I have a file like this:

Code:
2010-04-25 00:00:30,095 [ExecuteThread: '191' for queue: 'weblogic.kernel.Default']  INFO - [123456789]]- start process U100M4
2010-04-25 00:00:30,096 [ExecuteThread: '191' for queue: 'weblogic.kernel.Default'] DEBUG - [123456789]] -- call EJB
2010-04-25 00:00:30,709 [ExecuteThread: '191' for queue: 'weblogic.kernel.Default']  INFO - [123456789]- end processU100M4
2010-04-25 00:00:30,710 [ExecuteThread: '191' for queue: 'weblogic.kernel.Default'] DEBUG - got message=Sorry

I want to out put format.

Code:
2010-04-25 00:00:30 INFO - [123456789]]- start process U100M4
2010-04-25 00:00:30 DEBUG - [123456789]] -- call EJB
2010-04-25 00:00:30  INFO - [123456789]- end processU100M4
2010-04-25 00:00:30 DEBUG - got message=Sorry


How do I do this?

Thanks. Smilie
# 2  
Old 04-25-2010
Try this...

Code:
sed "s/\[ExecuteThread: '191' for queue: 'weblogic.kernel.Default'\]//" infile

# 3  
Old 04-25-2010
try out this

Code:
kamaraj@kamaraj-laptop:~/Desktop/testing$ cat unix_thread.txt  | awk '{printf ("%s %0.8s %s %s %s %s %s %s\n",$1,$2,$8,$9,$10,$11,$12,$13)}'
2010-04-25 00:00:30 INFO - [123456789]]- start process U100M4
2010-04-25 00:00:30 DEBUG - [123456789]] -- call EJB
2010-04-25 00:00:30 INFO - [123456789]- end processU100M4 
2010-04-25 00:00:30 DEBUG - got message=Sorry



---------- Post updated at 12:20 PM ---------- Previous update was at 12:17 PM ----------

Quote:
Originally Posted by malcomex999
Try this...

Code:
sed "s/\[ExecuteThread: '191' for queue: 'weblogic.kernel.Default'\]//" infile

small correction in the malcomex post

Code:
kamaraj@kamaraj-laptop:~/Desktop/testing$ sed "s/.....\[ExecuteThread: '191' for queue: 'weblogic.kernel.Default'\]//" unix_thread.txt 
2010-04-25 00:00:30  INFO - [123456789]]- start process U100M4
2010-04-25 00:00:30 DEBUG - [123456789]] -- call EJB
2010-04-25 00:00:30  INFO - [123456789]- end processU100M4
2010-04-25 00:00:30 DEBUG - got message=Sorry

# 4  
Old 04-25-2010
Is the text to delete always begins with "," and ends with "fault']" then try with:

Code:
sed 's/,.*t.]//g' file

Hope it helps.

Regards,
# 5  
Old 04-25-2010
Or:
Code:
sed 's/,[^]]*]//' infile

Code:
cut -c-19,84- infile

# 6  
Old 04-25-2010
thank all ^ ^
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need a command to remove the last word in the first line of a file

I have a eg file op.txt This is a cat This is a fat cat This is a fat black cat I want to remove only the word cat from the first alone .can somebody help. please do wrap your samples in CODE TAGS As per forum rules. (7 Replies)
Discussion started by: Sharks
7 Replies

2. Shell Programming and Scripting

Combine first two words ( country name ) into one word in every line of log file with 500 records

United States 1.2.3.4 80 10 1563790914 1 1932454179 1.2.3.6 55517 11.1.2.1 55517 Italy 1.2.3.4 80 10 1563790914 1 1932454179 1.2.3.6 55517 11.1.2.1 55517 India 1.2.3.4 80 10 1563790914 1 1932454179 1.2.3.6 55517 11.1.2.1 55517 south Africa 1.2.3.4 80 10 1563790914 1... (9 Replies)
Discussion started by: arm
9 Replies

3. UNIX for Advanced & Expert Users

Sort words based on word count on each line

Hi Folks :) I have a .txt file with thousands of words. I'm trying to sort the lines in order based on number of words per line. Example from: word word word word word word word word word word word word word word word word to desired output: word (2 Replies)
Discussion started by: martinsmith
2 Replies

4. Shell Programming and Scripting

USING sed to remove multiple strings/words from a line

Hi I use sed comnand to remove occurance of one workd from a line. However I need to removed occurance of dufferent words in ne line. Original-1 Hi this is the END of my begining Comand sed s/"END"/"start"/g Output-1 Hi this is the start of my beginig But I have more... (9 Replies)
Discussion started by: mnassiri
9 Replies

5. Shell Programming and Scripting

Remove last few words from Line

Hi I would like to remove last few words from File Could anybody Help on it. ps -ef | grep mgr.prm | awk '{print $10}' /opt/app/dummyd/xyz/dirprm/mgr.prm /opt/app/dummy/xyz/dirprm/mgr.prm /opt/app/dummy/xyz/dirprm/mgr.prm I want output like /opt/app/dummyd/xyz... (4 Replies)
Discussion started by: tapia
4 Replies

6. UNIX for Advanced & Expert Users

cut words based on the word count of a line

I would like to cut words based on the word count of a line. This over here inspired me with some ideas but I wasn't able to get what I needed. https://www.unix.com/shell-programming-scripting/105841-count-words-each-line-file-using-xargs.html If the line has 6 words I would like to use this.... (8 Replies)
Discussion started by: cokedude
8 Replies

7. Shell Programming and Scripting

Remove all words after first space from each line

My file looks like: asd absjdd sdff vczxs wedssx c dasx ccc I need to keep asd sdff wedssx dasx How do I do that experts?:wall::wall: (1 Reply)
Discussion started by: hakermania
1 Replies

8. Shell Programming and Scripting

How to remove all words starting from a matching word in a line

Hi Guys, I have a file like this: wwwe 1 ioie ewew yyy uuu 88 erehrlk 4 ihoiwhe lkjhassad lkhsad yyy mmm 45 jhash lhasdhs lkhsdkjsn ouiyrshroi oihoihswodnw oiyhewe yyy ggg 77 I want to remove everything after "yyy" and including "yyy" from each line in the file. So I want:... (2 Replies)
Discussion started by: npatwardhan
2 Replies

9. Shell Programming and Scripting

remove duplicate words in a line

Hi, Please help! I have a file having duplicate words in some line and I want to remove the duplicate words. The order of the words in the output file doesn't matter. INPUT_FILE pink_kite red_pen ball pink_kite ball yellow_flower white no white no cloud nine_pen pink cloud pink nine_pen... (6 Replies)
Discussion started by: sam_2921
6 Replies

10. Shell Programming and Scripting

remove first few words from a line

Hi All, Sample: 4051 Oct 4 10:03:36 AM 2008: TEST: end of testcase Checking Interface after reload, result fail I need to remove first 10 words of the above line and output should be like Checking Interface after reload, result fail Please help me in this regard. Thanks, (4 Replies)
Discussion started by: shellscripter
4 Replies
Login or Register to Ask a Question