O Universo não é uma idéia minha.
A minha idéia do Universo é que é uma idéia minha.
A noite não anoitece pelos meus olhos, a minha idéia da noite é que anoitece por meus olhos.
Fora de eu pensar e de haver quaisquer pensamentos
A noite anoitece concretamente.
E o fulgor das estrelas existe como se tivesse peso.
Fernando Pessoa
Pesquisar este blog
quinta-feira, 30 de julho de 2020
fd – A Simple and Fast Alternative to Find Command
Most of the Linux users are well familiar with the find command and the many cases it can be used. Today we are going to review an alternative to find command, called fd.
fd, is a simple, fast and user-friendly tool meant to simply perform faster compared to find. It is not meant to completely replace find, but rather give you an easy to use alternative that performs slightly faster.
Some of the notable features of fd:
Easy to use syntax – fd *pattern* instead of find -iname *pattern*.
In the example below, I have taken only the first 10 results for shorter output of the command.
# fd | head
fd Command Example
Let’s say we want to find all jpg files. We can use the “-e” flag to filter by file extension:
# fd -e jpg
fd – Find JPG Files
The “-e” flag can be used in combination with a pattern like this:
# fd -e php index
The above command will look for files with extension php and have the string “index” in them:
fd – Find String in Files
If you want to exclude some results, you can use the “-E” flag like this:
# fd -e php index -E wp-content
This command will look for all files with php extension, containing the string “index” and will exclude results from the “wp-content” directory.
fd – Exclude Files While Searching String in Files
If you want to specify a search directory, you simply need to give it as argument:
# fd
fd – Find Files in Directory
Just as find, you can use -x or --exec arguments to perform parallel command execution with the search results.
Here is an example where we will use chmod to change permissions of the image files
# fd -e jpg -x chmod 644 {}
The above will find all files with extension jpg and will run chmod 644 .
Here is some useful explanation and usage of the brackets:
{} – A placeholder which will be changed with the path of the search result (wp-content/uploads/01.jpg).
{.} – similar to {}, but without using the file extension (wp-content/uploads/01).
{/}: A placeholder that will be replaced by the basename of the search result (01.jpg).
{//}: Parent directory of the discovered path (wp-content/uploads).
{/.}: Only the basename, without the extension (01).
Conclusion
This was a brief review of the fd command, that some users may find easier to use and faster. As mentioned earlier in this article fd is not meant to completely replace find, but rather provide a simple usage, easier search and better performance. Fd does not take much space and is a nice tool to have in your arsenal.
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.