Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Problems with "grep -vf", and exclusion files Post 302877397 by Doug Lassiter on Saturday 30th of November 2013 06:13:30 PM
Old 11-30-2013
Problems with "grep -vf", and exclusion files

OK, this really has me bolluxed.

I'm using Mac 10.6.8, and I'm trying to do simple analysis of my Apache logs in Unix. Let's call that text file "log".

Now I want to remove from that file all lines with incomplete GETs, so I do

Code:
grep -vf exclude log > out

where the file "exclude" has lines (one each) for 206 , 304 , 403 , 404 , 405 , 500 (included spaces). Those are status codes whose lines I want to remove from the log file. That works great.

Oh, I'll get rid of requests for mp3s too. So I add to that exclude file a line with "mp3" in it. I run the command, and it goes off in never-never land.

If I use an exclude file with just "mp3" in it, it works fine. Lines containing "mp3" are removed.

If I use an exclude file with "mp3" and "invitation" it works fine. Those lines are removed.

But if I use an exclude file with three or more lines of alphabetical characters, like "mp3, "invitation", and "pdf", it goes off into never-never land.

The rule seems to be that the "exclude" file works great with a list of numbers, OR with two or less words (as in, not numbers). This seems just nuts. What's going on??? I have basic Unix expertise. Is this a Mac peculiarity, or is there something else going on?

Last edited by radoulov; 12-01-2013 at 05:11 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep to find content in between curly braces, "{" and "},"

problem String ~~~~~~~~~~~~~~~~~~ icecream= { smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" } aend = {smart vc4 eatr kalu} output needed ~~~~~~~~~~~~~~~~~~ smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" smart vc4... (4 Replies)
Discussion started by: keshav_rk
4 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Shell Programming and Scripting

ls -laR | grep "^-" | awk '{print $9}'| grep "$.txt"

Hi, I don't know hot to make this command work: ls -laR | grep "^-" | awk '{print $9}'| grep "$.txt" It should return the list of file .txt It's important to search .txt at the end of the line, becouse some file name have "txt" in their name but have other extensions (13 Replies)
Discussion started by: DNAx86
13 Replies

4. UNIX for Dummies Questions & Answers

How to use the "grep/egrep" command to search files.

Hi Team, I am new to this forum and also trying to learn Unix. I will highly appriciate your help if you can help me to get the right command . {{{ I use the command " today | egrep '(10:| 11: )' | grep ERROR " to grep all the files that has been error betweeen 10 to 11... (6 Replies)
Discussion started by: rkhanal
6 Replies

5. AIX

xx=`date +"%a %b %d"`;rsh xxx grep "^$XX" zzz ?

AIX 4.2 I am trying to do an rsh grep to search for date records inside server logs by doing this : xx=`date +"%a %b %d"` rsh xxx grep "^$XX" zzz gives : grep: 0652-033 Cannot open Jun. grep: 0652-033 Cannot open 11. But if I do : xx=`date +"%a %b %d"` grep "^$XX" zzz it works... (2 Replies)
Discussion started by: Browser_ice
2 Replies

6. Shell Programming and Scripting

"Join" or "Merge" more than 2 files into single output based on common key (column)

Hi All, I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations: 1. I am restrained to 2 input files only. 2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Discussion started by: Katabatic
1 Replies

7. Shell Programming and Scripting

ps -ef | grep "string1" "string2" " "string3"

Hi all, can any one suggest me the script to grep multiple strings from ps -ef pls correct the below script . its not working/ i want to print OK if all the below process are running in my solaris system. else i want to print NOT OK. bash-3.00$ ps -ef | grep blu lscpusr 48 42 ... (11 Replies)
Discussion started by: steve2216
11 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

10. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies
dr_symlinks(1)							  USER COMMANDS 						    dr_symlinks(1)

  NAME
      dr_unsort - unsort the current mpd playlist

  SYNOPSIS
      dr_unsort

  DESCRIPTION
      dr_unsort invokes unsort(1) on the current audio playlist as used by mpd.  Use it if you'd like some variation in your music.

  EXAMPLE
      If The_Beatles/The_White_Album_I/03-Glass_Onion.ogg is the current playing track and your current playlist looks like

	Flying_Lotus/Los_Angeles/01 Brainfeeder.mp3
	The_Beatles/The_White_Album_I/01-Back_in_the_U.S.S.R..ogg
	The_Beatles/The_White_Album_I/02-Dear_Prudence.ogg
      > The_Beatles/The_White_Album_I/03-Glass_Onion.ogg
	The_Beatles/The_White_Album_I/04-Ob-La-Di,_Ob-La-Da.ogg
	The_Beatles/The_White_Album_I/05-Wild_Honey_Pie.ogg
	The_Beatles/The_White_Album_I/06-The_Continuing_Story_of_Bungalow_Bill.ogg
	The_Beatles/The_White_Album_I/07-While_My_Guitar_Gently_Weeps.ogg
	Flying_Lotus/Los_Angeles/02 Breathe . Something_Stellar STar.mp3
	Flying_Lotus/Los_Angeles/03 Beginners Falafel.mp3
	Flying_Lotus/Los_Angeles/04 Camel.mp3
	Napalm_Death/The_Peel_Sessions/01-The_Kill-Prison_Without_Walls-Dead_Part_1.mp3
	Napalm_Death/The_Peel_Sessions/02-Deceiver-Lucid_Fairytale-In_Extremis.mp3
	Napalm_Death/The_Peel_Sessions/03-Blind_To_The_Truth-Negative_Approach-Common_Enemy.mp3
	Napalm_Death/The_Peel_Sessions/04-Obstinate_Direction-Life-You_Suffer_Pt_2.mp3
	Flying_Lotus/Los_Angeles/05 Melt!.mp3
	Flying_Lotus/Los_Angeles/06 Comet Course.mp3
	Flying_Lotus/Los_Angeles/07 Orbit 405.mp3
	Flying_Lotus/Los_Angeles/08 Golden Diva.mp3

      invoking dr_unsort will yield something like e.g.

	Flying_Lotus/Los_Angeles/01 Brainfeeder.mp3
	The_Beatles/The_White_Album_I/01-Back_in_the_U.S.S.R..ogg
	The_Beatles/The_White_Album_I/02-Dear_Prudence.ogg
      > The_Beatles/The_White_Album_I/03-Glass_Onion.ogg
	Flying_Lotus/Los_Angeles/02 Breathe . Something_Stellar STar.mp3
	The_Beatles/The_White_Album_I/04-Ob-La-Di,_Ob-La-Da.ogg
	Napalm_Death/The_Peel_Sessions/01-The_Kill-Prison_Without_Walls-Dead_Part_1.mp3
	Flying_Lotus/Los_Angeles/03 Beginners Falafel.mp3
	The_Beatles/The_White_Album_I/05-Wild_Honey_Pie.ogg
	Napalm_Death/The_Peel_Sessions/02-Deceiver-Lucid_Fairytale-In_Extremis.mp3
	Flying_Lotus/Los_Angeles/04 Camel.mp3
	The_Beatles/The_White_Album_I/06-The_Continuing_Story_of_Bungalow_Bill.ogg
	Napalm_Death/The_Peel_Sessions/03-Blind_To_The_Truth-Negative_Approach-Common_Enemy.mp3
	Flying_Lotus/Los_Angeles/05 Melt!.mp3
	The_Beatles/The_White_Album_I/07-While_My_Guitar_Gently_Weeps.ogg
	Napalm_Death/The_Peel_Sessions/04-Obstinate_Direction-Life-You_Suffer_Pt_2.mp3
	Flying_Lotus/Los_Angeles/06 Comet Course.mp3
	Flying_Lotus/Los_Angeles/07 Orbit 405.mp3
	Flying_Lotus/Los_Angeles/08 Golden Diva.mp3

  WARNING
      Due to limitations in the mpc/mpd protocol, dr_unsort needs filesystem level write access to mpd's playlist directory.

  ENVIRONMENT
      dr_unsort honors strings DR_PLAYLISTS (mpd's playlist directory) and DR_UNSORT (unsort pathname).

  SEE ALSO
      unsort(1), available from http://packages.debian.org/unsort.

  COPYRIGHT AND LICENSE
      This manpage is copyright 2010, 2011 Joost van Baal <joostvb-draai@mdcc.cx>.

      Draai is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, as published by the Free
      Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed	WITHOUT  ANY  WAR-
      RANTY. You should have received a copy of the GNU General Public License along with draai. If not, see http://www.gnu.org/licenses/.

  AUTHOR
      Joost van Baal <joostvb-draai@mdcc.cx>

  dr_symlinks 20110603						     03 juin 2011						      dr_symlinks(1)
All times are GMT -4. The time now is 09:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy