0

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” ?

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182
maihabunash
  • 1,632
  • 9
  • 34
  • 60
  • Support of a 3rd party script is somewhat out of scope for Stack Overflow. – Sobrique Mar 11 '15 at 10:14
  • I think some stack overflow users have the experience to help with this issue , so please don’t close this case , let’s wait to users answers – maihabunash Mar 11 '15 at 10:44
  • Whether they do or not doesn't really change whether it's 'on topic' or not. – Sobrique Mar 11 '15 at 10:48
  • I am really in troubles because I send this question to server fault and super user and Linux & Unix , all them not know the answer , and this issue is very critical for me ,so who can help me ?? , I need to give solution to my company otherwise it will be very bad – maihabunash Mar 11 '15 at 10:57
  • In the real world, for critical issues for companies, they typically pay for support. And then get service level agreements. – Sobrique Mar 11 '15 at 11:02
  • yes , the problem is that the ack.pl is free SW , so we trust the users and who is use this tool – maihabunash Mar 11 '15 at 11:23
  • Please note that there is an ack-users mailing list, as well as the issues queue on the GitHub project: https://github.com/petdance/ack2. – Andy Lester Mar 11 '15 at 14:10
  • And no, ack does not look at file permissions, as @mob points out below. – Andy Lester Mar 11 '15 at 14:11
  • maybe we can do it by triky way , or combine the find with the ack.pl - what you think ? as Mob do it but with grep – maihabunash Mar 11 '15 at 14:16
  • Why are you using ack instead of grep? ack is designed for searching source code, not arbitrary text files, and it seems that you would not have source code in /etc. – Andy Lester Mar 11 '15 at 15:30
  • I use the ack.pl to search IP's and string on text files and ASCII files , ack.pl is great tool to search words/char , and I can set in the ack.pl the dirs that I want to ignore and many mant other functions – maihabunash Mar 11 '15 at 15:45
  • ack.pl is searching tool not matter what the type of the file – maihabunash Mar 11 '15 at 15:47

1 Answers1

2

ack (more official and up-to-date version here) does not examine file permissions and cannot filter on them. So what about a find+ack or find+grep idiom?

find /etc -not -perm /o+S -type f -exec grep -l STRING_TO_FIND {} \;

(not tested)

mob
  • 117,087
  • 18
  • 149
  • 283
  • Hi MOB , in this example I see only find + grep , but how to combine the find + ack.pl so it will filter the relevant files? ( +1 ) – maihabunash Mar 11 '15 at 14:04
  • hi Mob , can we do it , I mean to combine the find with ack.pl ? – maihabunash Mar 11 '15 at 14:18
  • The advantages of `ack` over grep are (1) more expressive Perl regular expressions and (2) automatic recursing through subdirectories. You pass the `-Q` option to `ack` which means you don't care about (1). `find` also recurses through subdirectories so you don't need feature (2). But otherwise, you could replace the word `grep` above with `ack` and everything would work pretty much the same (if a tad slower). – mob Mar 11 '15 at 14:27
  • so the syntax will be --> find / -not -perm /o+S -type f -exec ack.pl ........... \; – maihabunash Mar 11 '15 at 14:43
  • I put the "/" because I want to scann all the OS , and ack.pl will be with the relevant path – maihabunash Mar 11 '15 at 14:44