2

Say that I have the following files in the current directory :

aa01.txt
aa02.txt
bb01.txt
bb02.txt
cc01.txt
...

Is there a way I can search for a given pattern and select ALL the matching files at once (not just selecting the first matching file and then selecting the next one, then the next one...), so that I can process them further (e.g. delete, move, copy... them as a group)?

For example, say I'd like to select all the files above containing the string "aa" (maybe to delete them), or maybe all the file containing "02" (maybe to copy them)...

3

I usually do this by

  • setting a filter first (with zf + expression),
  • then selecting everything in the result (v) and
  • turning the filter off again (zf + Enter).
3

If you want to use a regular expression, the quickest is the mark command, e.g.

:mark ^aa

The scout command with the -m flag will also achieve the same result, and also allows for glob patterns for instance. See the man page for more details.

0

If it is Ubuntu/centos machine,you can use below command in terminal to search the files

sudo find / -type f -name "*.txt"

find command

where the " * " denotes all the .txt files, you can replace with the particular file name like "xyz.txt".

to search and delete the particular file series,use the below command

sudo find / -type f -name "aa01.txt" || rm -f aa01.txt

This will works for sure!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.