vifm search files in subfolders - file-search

How can I search files just like with / command but recursively scanning subfolders?
Or maybe there are other approaches to get a list of files that match some pattern in the current folder including all subfolders.

:find command
There is :fin[d] command for that. Internally it invokes find utility (this is configurable via 'findprg' option), so you can do everything find is capable of. That said, in most cases the simple form of the command suffices:
:find *.sh
Note that by default argument is treated as regular file pattern (-name option of find), which is different from regular expressions accepted by /. For searching via regexp, use:
:find -regex '.*_.*'
If you want to scan only specific subfolders, just select them before running the command and search will be limited only to those directories.
:find command brings up a menu with search results. If you want to process them like regular files (e.g. delete, copy, move), hit b to change list representation.
Alternative that uses /
Alternatively you can populate current view with list of files in all subdirectories with command like (see %u):
:!find%u
and then use /, although this might be less efficient.

Related

VS Code: Search multiple directories

When searching, VS Code has the ability to list files to include to scope the search. This is used by default when using the "find in folder" feature. For example, searching src results in ./src as the files to include.
Is there a syntax I can use to list multiple directories here? For example, I want to search ./src and ./lib in one search.
Did you try a comma like ./dir1, ./dir2? For me it seems to work
By the way, here is the documentation of 'files to include': https://code.visualstudio.com/Docs/editor/codebasics#_advanced-search-options
In particular, you can use glob notation. Also, VS Code will include/exclude certain directories or files by default, depending on your settings.json, in case anyone still sees unexpected behaviour.

Include only specific file patterns in meld comparison

I want to compare directories with Meld, but only specific file patterns.
E.g., only *.c;*.cc;*.icc;*.h files.
Meld can use File Filters, but I could only use them for exclusion filtering specific file patterns. That approach is not useful for me, I guess.
Can an inclusion filter be applied?
I tried with the idea of "double negation": Excluding "everything but *.c;*.cc;*.icc;*.h", which in effect would include only those patterns.
I tried using File Filters which worked well for listing "everything but ..." using ls -d -- <my_filter> at the command line (see this). I assume this is a necessary (but not sufficient) condition for any filter to work in Meld.
None of these worked:
!(*.c|*.h|*.cc)
!(*#(.c|.h|.cc))
!(*.#(c|h|cc))
Note: I do not mean to use any type of Text Filter, since I do not care at this point about the contents of files, but only about the file names.
Note : I have bash and
$ shopt extglob
extglob on

Use wildcards with perforce move

I would like to move files filtered using wildcards to subfolders, however perforce move does not accept my usage of the wild card.
given this structure
filea_mk1.txt
fileb_mk2.txt
mk1/
mk2/
to move all files some thing like p4 move ./... ./mk1/... works, however when replacing the selected file to use wild cards I get:
p4 edit filea_mk1.txt
p4 move *_mk1*.* ./mk1/...
Usage: move [-c changelist#] [ -f ] [ -k ] [-t type] from to
Missing/wrong number of arguments.
I have thought about using p4 fstat as that does accept the wildcards, and could then pass filenames into to xargs.
p4 fstat *_mk1*.*
However I can not get the -A options correct to only show client names.
TL;DR
Is there a way to filter *_mk1*.* into the mk1 folder and *_mk2*.* into the mk2 folder, using perforce commands?
Instead of this:
p4 move *_mk1*.* ./mk1/...
Do this:
p4 move "*_mk1*.*" "mk1/*_mk1*.*"
Note the double quotes to keep the shell from expanding the asterisks.
Alternatively, this simpler form will probably work fine unless the paths are trickier than your example makes them appear:
p4 move ..._mk1... mk1/..._mk1...
I believe that what's happening here is that your operating system shell is expanding the asterisk wildcards in your command, so the actual command that the Perforce server is seeing is:
`p4 move filea_mk1.txt fileb_mk1.txt ./mk1/...`
and that command has three file-spec arguments, rather than the expected two file-spec arguments, hence the Usage: message that you receive.
By using operating-system filenames (*_mk1*.* and ./mk1/...), you are providing the file-spec arguments in what Perforce calls "local" syntax.
But this causes your operating system shell to think it should expand the wildcards, when what you want is to have the Perforce server expand the wildcards.
You can try using different quoting strategies for your arguments, to defeat that local wildcard expansion, but this is a situation where you can benefit from using one of the other forms of file-spec syntax, either "client" syntax" or "depot" syntax.
For example, suppose that your client root is actually located in a section of the depot that begins with the path //depot/projects/project1/main/.
Then, you could specify your command as:
`p4 move //depot/projects/project1/main/*_mk1*.* //depot/projects/project1/main/mk1/*_mk1*.*`
In this case, these file-spec arguments will not be seen as syntax that your operating-system shell should expand, so it will leave the arguments alone and pass them unaltered to the server, so that the Perforce server can perform the wildcard expansion, rather than allowing your shell to perform the wildcard expansion.
Note that I also re-specified your wildcard expansion slightly. The Perforce move command, like the integrate command and several other commands, is typically happiest if the "wildcards on the left side" match up with the "wildcards on the right side", so that when it is constructing new destination file names for the files being moved, it can replace the wild-carded elements 1-1 with the wild-carded elements from the source file names.

Search for files with MATLAB

My question is how to use MATLAB to search for a certain type of files in a folder. I give an example to detail on my question:
Suppose we have the following folder as well as files in it:
My_folder
Sub_folder1
Sub_sub_folder1
a.txt
1.txt
2.txt
Sub_folder2
3.txt
abc.txt
In this example, I want to find all the .txt files in My_folder as well as its sub-folders. I was wondering what I could do with MATLAB. Thanks!
To my knowledge Matlab doesn't have an inbuilt function to do recursive directory searches, however there are a couple available for download on Matlab Central: here and here.
Alternatively you could write your own recursive function and use the dir function to search at each level for files matching your criterea or other directories to recurse into.
I agree with the Matlab Central options -- another method which I've used when MLC is not an option (no network, or customer computer, etc) is the quick and dirty dos commands:
dos(['dir /s/b ' mywildcard])
The /s will do a recursive directory search for whatever wildcards you specify, and /b will make it so you only get filenames (complete will full path, but no headers, file sizes, etc).
This is obviously platform dependant, so is mostly used when you are forced to work without your "standard" set of utilities you've accumulated.
Even though an answer has been accepted, I would like to point out Matlab's dir function.
This built-in function returns the contents of the folder in question. Furthermore, it indicates which content is a folder of its own. Therefore, with a little loop one could use this function to search sub-directories as well.

How to search a text among c files under a directory

I've looked through several similar questions, but either I didn't understand their answer or my question is different than theirs. So, I have a project contains many subdirecties and different type of files. I would like to search a function name among those .C files only.
Some information on the web suggest to use "Esc x dired-do-query-replace-regexp". However, this will search not just C files, but also other file like .elf which isn't helpfule in my case. Other people sugget to use TAG function, but it will require me to type "etags *.c" for every subdirectory which is also impossible.
How should I do this while working on those large scale software project?
Thanks
Lee
Use ack-grep on linux
ack-grep "keyword" -G *.c
My favorite: igrep-find, found in the package igrep.el. Usage is:
M-x igrep-find some_thing RET *.C
There's the built in grep-find, docs here, but I find it awkward to use.
For a more general answer, see this similar question: Using Emacs For Big Big Projects.
if you're on linux, you can use grep to find files with a certain text in them. you would then do this outside of emacs, in your shell/command prompt. here's a nice syntax:
grep --color=auto --include=*.c -iRnH 'string to search for' /dir/to/search/
the directory to search can be specified relative, so if you're in the directory you want to use as the root directory for your recursive search, you can just skip the whole directory address and specify a single dot.
grep --color=auto --include=*.c -iRnH 'string to search for' .
the part --color=auto makes some text highlighted. --include=*.c is the part that specifies what files to search. in this case, only files with the c-extension. the flag i makes stuff case insensitive, the flag R makes the search recursive, the flag n adds the line number to the report, and the flag H adds the file path to the report.
To breed find and grep there is find-grep function, there you can change the invocation string to find . -name *.c etc. Make it a function, if You like. Then You use eg. C-x` et al. to navigate the results.
To search among the files in one directory i use lgrep, it prompts you in which files to search.
You can use cscope and xcscope.el : http://www.emacswiki.org/emacs/CScopeAndEmacs
Try with dired: place the cursor on the directory name to search, type A and in the minibuffer the text to find.