How to find files that aren't in a given folder(s)?
Could anyone please tell me a command to search my computer for a file ("gentoo.txt") but ignore one folder ("UVWX")
or ignore multiple folders ("UVWX2", "UVWX3", and "UVWX4")? Thanks in advance for helping a command line newbie. |
The command ag might be what you are looking for here. It very versital and easy to use once you get the hang of its flags.
For example: Code:
ad gentoo.txt -l --ignore-dir=/etc/man Code:
ad gentoo.txt -l --ignore-dir=/etc/man --ignore-dir=/usr/src Hope that is what you are looking for and helps out. |
Thank you
AuroraZero: Thank you very much, I'll try that... I appreciate the help, and have a good day/night.
|
Sounds like homework - in the normal course of events, why would a user care ?.
"find" is the obvious answer, but "locate" is easier on the machine if the updatedb has been run. |
Searching with "find" and/or "locate"?
Quote:
If I use "find" and "locate", how do I enter the command, and with what flags or options? Thank you. |
Locate
Code:
$ locate file_name |
Re: "locate"
Quote:
|
Code:
locate file_name | grep -v ignorefolder The $ is only there as an example for a command prompt. With a # (opposed to the $) you are told it has to be run as root. |
@domoarigato, I'm bit confused here. The title says 'How to find files that aren't in a given folder(s)?' Well, you cannot find those files there, because they are NOT there... What I'm missing here?
Why would search result will show folders like UVWX, UVWX3 etc, when you search for file gentoo.txt? Are there multiple copies of gentoo.txt files also available in folders that you have mentioned earlier? Is this specific to Gentoo Distro? Anyway, possible two ways to find gentoo.txt file are Code:
locate '*gentoo.txt' | grep -v 'UVWX*' |
Find files that are not in UVWX* directories.
Most precise is Code:
locate 'gentoo.txt' | grep -v '/UVWX[^/]*/' -prune actually skips the directories - this is faster than processing but not printing them. You need -print in order to suppress the default print at -prune. |
Much thanks
Thanks to everyone for your replies. I appreciate all the help and I'll try your suggested commands...
|
All times are GMT -5. The time now is 03:49 PM. |