Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ack: Excluding only one directory but keeping all others with the same name

Tags:

ack

My folder structure looks like this:

/app /app/data ... /app/secondary /app/secondary/data 

I want to recursively search /app, including /app/data. I do not want to search /app/secondary/data however. This what I have so far:

ack --ignore-dir=data searchtext ack --ignore-dir=secondary/data searchtext 

The first command is ignoring both directories and the second one is ignoring neither of them. From within the app folder, what should my ack command look like?

like image 828
mattalxndr Avatar asked May 09 '10 23:05

mattalxndr


People also ask

Do I need to send an ACK for every segment?

For instance, segments with only the ACK or RST flag set do not require an ACK. Additionally, if delayed ACKs are in use, then there may not be an ACK every segment, however generally this requires that an ACK be sent for every other segment.

Why do I get an ack when I send data?

The reason for the ACK is that a NACK is simply not sufficient. Let's say I send you a data stream of X segments (let's say 10 for simplicity). You are on a bad connection, and only receive segments 1, 2, 4, and 5. Your computer sends the NACK for segment 3, but doesn't realize there should be segments 6-10 and does not NACK those.

Is it possible to design an ACK protocol without Nak?

It is perfectly feasible to design a protocol supporting reliable transfer and flow control only with ACK, without NAK (with retransmission by Transmitter in case Transmitter does not receive an ACK, retransmission mechanism that is needed in any case). Show activity on this post.

What is the difference between ACK and Nack?

If you use ACK, the sender will stop sending and keep its backlog until the link is restored. If you use NACK instead, then the receiver may eventually tell you that it has not received the packet that fell off the sender's backlog since a long time, and the connection is essentially unrecoverable. Show activity on this post.


2 Answers

The older versions of ack can only take the folder name, not the folder path. As of version 1.93_02, they've added this ability in:

1.93_02     Wed Oct  6 21:39:58 CDT 2010    [ENHANCEMENTS]    The --ignore-dir option now can ignore entire paths relative    to your current directory.  Thanks to Nick Hooey.  For example:         ack --ignore-dir=t/subsystem/test-data 

(From betterthangrep.com/Changes)

You can check which version you have with --version:

ack --version 
like image 86
Erin Heyming Avatar answered Sep 25 '22 00:09

Erin Heyming


This answer is for versions of Ack prior to 2, see This answer for versions of Ack >=2.

The first one is ignoring both because they both have 'data' as a sub-directory and ack searches sub-dirs by default. So it will ignore any sub-dir with that name. Unfortunately, your second way doesn't work either. This works for me:

ack -a searchtext -G '^(?!.*secondary/data.*).*$' 

Instead of -a to search all files, see ack-grep --help=types to search for only certain file types, eg --type=text

like image 38
rkulla Avatar answered Sep 24 '22 00:09

rkulla