3

I am using the ack.pl tool in order to search string or IP’s in files

The official site of ack.pl is - http://beyondgrep.com/documentation/

Example of ack.pl CLI ( want to find the string STRING_TO_FIND in files under /etc )

  /tmp/ack.pl -Q -a -l --max-count=1  STRING_TO_FIND  /etc

But sometimes ack.pl is stuck on files as:

  ---S--l---   1 root     root          0 Mar 10 04:25  /opt/POP_lock

From MAN paget "S" attr mean that:

Using an upper-case "S" instead of a lower-case "s" tells the filesystem to immediately write the file to disk, instead of storing it in a buffer. (Note also, that we left the "s" attribute this time, so that we now have two attributes set for this file.)

So my question is:

How ack.pl can ignore the files with “S” , Or what the ack.pl flags that shuld ignore this files with “S” ?

maihabunash
  • 6,973
  • 19
  • 64
  • 80
  • Consider adding [tag:ack] to your list of tags – Arkadiusz Drabczyk Mar 10 '15 at 19:56
  • I add the ack.pl in the flags –  Mar 10 '15 at 20:02
  • What man page are you quoting as saying that an upper-case “S” instead of a lower-case “s” tells the filesystem to immediately write the file to disk, instead of storing it in a buffer?  I was about to refer you to the question [File with permissions `---S--l---`](http://unix.stackexchange.com/q/189240/23408) until I saw that you wrote it. – Scott - Слава Україні Mar 31 '15 at 23:56

1 Answers1

1

Are you sure that it’s the “S” that’s causing the problem?  As I explained in my answer to your previous question, the “l” signifies that your operating system and filesystem support mandatory file locking, and mandatory file locking is enabled for this file.  I doubt that it’s a coincidence that both files you give as examples (in this question and the previous one) have names that end with _lock.  These files are probably — guess what? — locked!  This could prevent ack (or any other program) from reading them.
(The above is the answer to the question, “Why can’t ack read these files?”, which, I realize, you didn’t ask.)

Search for all files that have the “l” mode bit set using the

find /etc -perm -2000 ! -perm -010

command (which I presented in my answer to your previous question).  See whether all the files have names that end with _lock.  Then do

find /etc -name "*_lock" –ls

to verify that all _lock files have the “l” mode bit set.  If there is a one-to-one correspondence (or, in general, if there are no _lock files that you need to search), exclude them from your search by filename pattern.

I don’t have access to a copy of ack to test with, but, from the documentation, it looks like you may be able to do this with --ignore-file="match:/.*_lock/", or something like that.