Linux - find files by file name and directory name

Linux - find files by file name and directory name

Hi,

I have a task from school - to search for files on the Linux system, but it is to be searched at the same time both by the file name and by the name of the directory in the given location.

E.g. find in the directory "/home/user" a file containing the word "top" in the name, this file should then be located in the directory named "dir2". Please advise how to do it?

Thanks

REPLY


Hello,

You can search for files by file name and by directory name on Linux in your case as follows:
find /home/user -type f -path '*dir2*/*' -name '*top*.*'

Alternative:
find /home/user -type f -path '*dir2*/*top*.*'

Související obsah

linux

bash

terminal

find

Komentáře

Vaše reakce na Linux - vyhledat soubory dle názvu souboru a dle názvu adresáře

Reference

Podívejte se na naše reference

Prohlédnout

Aplikace

Podívejte se na naše aplikace

Prohlédnout

Co umíme?

Podívejte se co umíme

Prohlédnout

Co umíme?

Vytváříme sofistikované aplikace pro náročné

Od webových aplikací přes android až po převodové můstky či složité informační systémy.

Podívejte se k nám

Máte ještě čas? Podívejte se na další rubriky

Tento web používá soubory cookie. Dalším procházením tohoto webu vyjadřujete souhlas s jejich používáním.. Více informací zde.