Issue Filtering Tail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issue Filtering Tail
# 1  
Old 11-13-2009
Issue Filtering Tail

Hi Folks,

I have a log that contains data as shown below:

11:59:43,144 [strategy.SNTH] (1,850) Signal : ....
11:59:44,109 [strategy.SNTH] (1850) Bps : .....


I wish to remove "[strategy.SNTH]" from all lines and it is on the start of every line. I have achieved that successfully using the command:

tail -f imp.log | sed 's/\ \[\<strategy.SNTH\>\]//g'

OR

tail -f imp.log | perl -pe "s/\ \[strategy\.SNTH\]//g"


I also wish to remove all lines containing the word "Bps". I achieved that using the following command:

tail -f imp.log |grep -v 'Bps'

The issue is, I cannot figure out how to string the two commands together.

Help please!

Regards,
Umair

---------- Post updated at 12:15 PM ---------- Previous update was at 12:14 PM ----------

And something to remove the milliseconds at the start of each line would be much appreciated too.

11:59:44,109 to just 11:59:44

Thanks.
# 2  
Old 11-13-2009
one way:

Code:
tail -f imp.log | sed -n '/Bps/!s/\ \[\<strategy.SNTH\>\]//g;s/\([0-9][0-9]\),[^ ]*/\1/;p'

# 3  
Old 11-13-2009
Thanks Tytalus but it doesn't entirely work. I'm getting the following results from your query:

11:59:43 (1,850) Signal : ....
11:59:44 [strategy.SNTH] (1850) Bps : .....
11:59:43 (1,850) Signal : ....
11:59:44 [strategy.SNTH] (1850) Bps : .....
11:59:43 (1,850) Signal : ....
11:59:44 [strategy.SNTH] (1850) Bps : .....
11:59:43 (1,850) Signal : ....
11:59:44 [strategy.SNTH] (1850) Bps : .....
11:59:43 (1,850) Signal : ....
11:59:44 [strategy.SNTH] (1850) Bps : .....


The millseconds are gone and for the correct signal lines [strategy.SNTH] is gone too but the Bps lines have not been filtered out.
# 4  
Old 11-13-2009
Code:
tail -f imp.log | nawk '!/Bps/' | sed -e 's/\ \[\<strategy.SNTH\>\]//g' -e 's/\([0-9][0-9]\),[^ ]*/\1/g'



---------- Post updated at 02:47 PM ---------- Previous update was at 02:40 PM ----------

This is a slightly stronger match: -

Code:
tail -f imp.log | nawk '!/Bps/' | sed -e 's/\ \[\<strategy.SNTH\>\]//g' -e 's/\([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\),[0-9][0-9]*/\1/g'



---------- Post updated at 02:59 PM ---------- Previous update was at 02:47 PM ----------

Your pattern for strategy.SNTH is a little overcomplicated: -

Code:
s/ \[strategy.SNTH\]//g

is sufficient
# 5  
Old 11-13-2009
Thanks for that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tail +

because the tail +2 on the first line gives me the file name pomga I do not want anything like what I miss tail +2 ejemplo.txt ouput ==> ejemplo.txt <== 1 2 3 4 5 6 7 8 9 10 (2 Replies)
Discussion started by: tricampeon81
2 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Tail command issue in Linux

Hello, When I am trying to use tail +13 filename.csv it is throwing an error. tail: cannot open `+13' for reading: No such file or directory and then prints last 10 lines of the file. (File is present on the path) But when i try tail -13 filename.csv it runs perfectly. Could I have... (5 Replies)
Discussion started by: AnkitSenghani
5 Replies

3. Shell Programming and Scripting

Joining multiple files tail on tail

I have 250 files that have 16 columns each - all numbered as follows stat.1000, stat.1001, stat.1002, stat.1003....stat.1250. I would like to join all 250 of them together tail by tail as follows. For example stat.1000 a b c d e f stat.1001 g h i j k l So that my output... (2 Replies)
Discussion started by: kayak
2 Replies

4. UNIX for Dummies Questions & Answers

Grep filtering issue

Hi, I am on uname -a HP-UX mymachine B.11.31 U ia64 3223107173 unlimited-user license ps -exx| grep java | grep -i "GrafiteEventsInterfaces*" 19955 ? 55:22 /opt/app/app1/jdk150_07/bin/IA64N/java -server -Xms1024m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m... (2 Replies)
Discussion started by: mohtashims
2 Replies

5. Shell Programming and Scripting

AWK / tail Issue

Hello, I am using a tail command to fetch the line before last in a log file. the two last lines are as followed: 11-01-16 11:55:45.174 | CClientObject::InitTraceLevelInCache Starting CClientObject::InitTraceLevelInCache End I am doing a awk statement to gather only the numeric... (1 Reply)
Discussion started by: LiorAmitai
1 Replies

6. Shell Programming and Scripting

tail issue!

Hi, I had few scripts which were running fine on linux: uname -a Linux ######### 2.6.9-89.ELsmp #1 SMP Mon Apr 20 10:33:05 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux from some front end application. Recently there was a migration of this application on some other linux m/c: uname -a... (4 Replies)
Discussion started by: dips_ag
4 Replies

7. Shell Programming and Scripting

Report filtering - Weird issue and interesting - UrgentPlease

Hi, Could any one help me to extract data from a report. I would like to get the two lines which are just below the separations I have a report like this -------------------------------------------------------------------------- Pid Command Inuse Pin Pgsp Virtual... (2 Replies)
Discussion started by: ajilesh
2 Replies

8. Shell Programming and Scripting

Sed filtering issue

The problem I have is that I have 23,000 records I need to sort through to pull out LEN: XXXX XX XX XX XX and NCOS: XXX entries from so I can insert them into a database. But some of my records include TYPE: ISDN, THE DN IS UNASSIGNED, or INVALID entries in between some records and I would like... (2 Replies)
Discussion started by: roachmmflhyr
2 Replies

9. Shell Programming and Scripting

tail -f

I am trying to extract a particular line from a.log which keeps appending every sec and output that into a newfile b.log which should append itself with filtered data received from a.log I tried tail -f a.log |grep fail| tee -a b.log nothing in b.log tail -f a.log |grep fail >>b.log ... (4 Replies)
Discussion started by: wannalearn
4 Replies

10. Shell Programming and Scripting

using tail -f

Working in HP-UX 10.20. I eventually want to write a bourne shell script to handle the following problem, but for now I am just toying with it at the command line. Here's what I am basically trying to do: tail -f log_X | grep n > log_Y I am doing a tail -f on log_X . Once it sees "n", I... (6 Replies)
Discussion started by: cdunavent
6 Replies
Login or Register to Ask a Question