Вопрос: Как найти файл в Linux?

 

Part II: How to Find Files in the Linux File System Using the find Command

Видео взято с канала: Ed Walsh


 

Linux команда grep поиск фрагмента текста в файле (файлах).

Видео взято с канала: IT4each com


 

How to Find Files in Linux | Learning Terminal

Видео взято с канала: Chris Titus Tech


 

Поиск файлов в linux Команда find linux опция часть2

Видео взято с канала: Proffi services


 

LPIC 104.7 Поиск и расположение команд и файлов в Linux

Видео взято с канала: Kirill Semaev


 

Поиск файлов в linux. Команда find linux опция -name часть1

Видео взято с канала: Proffi services


 

Linux команда find команда поиска файлов.

Видео взято с канала: IT4each com


11 комментариев

  • Linux команда find команда поиска файлов.

    Ссылка на видео «Linux/Ubuntu шаблоны подстановки (wildcards).»
    https://www.youtube.com/watch?v=BxEIYeNRCGE

    Ссылка на видео «Linux навигация относительные и абсолютные пути (ссылки).»
    https://www.youtube.com/watch?v=ShBhgZJ2ADs

    #!/bin/bash
    # find поиска файла по параметрам

    # 0:18 поиск файла по имени в текущей директории
    find -name file_name

    # 1:05 поиск файла по имени в текущей директории без учёта регистра
    find -iname file_name

    # 2:06 поиск файла по имени в домашней директории без учёта регистр
    find -iname file_name

    # 2:21 поиск файла по имени по всей файловой системе без учёта регистра
    find / -iname file_name

    # 2:51 поиск по имени с помощью шаблонов подстановки
    find -iname fi?e_nam?
    find -iname f*

    # 4:20 поиск по размеру (все, что больше)
    find -size +1000k

    # 4:51 поиск по размеру (все, что меньше)
    find -size -1k

    # 5:07 найти пустой файл
    find -empty

    # 5:44 справка
    find -help

  • For people who think the least amount of characters typed in terminal is best, enable globbing and use «ls **» with grep. Less optimized than find (probably, idk), but quick and useful if you’re already somewhere deep in your filesystem (don’t use it in root dir; it grabs every file from every subdirectory and will take hours to finish, or give up after 5 minutes).

  • I’ve always preferred to enable globbing and use «ls ** | grep -i [stuff]» to find things, just cause I never got used to find. However, filtering by time and size does sound pretty powerful, but I’m not sure that I have a use for that. Reassuring to know that this video exists if I ever find myself needing this command! Great vid!

    Edit: I realize that my preferred method probably isn’t as efficient as whatever algorithms/methods the find command uses, and can probably do a full search without me having to think too hard about narrowing my search. Methods like using information directly from the system, rather than expanding my grep query into a massively clustered regex command…. I’ll come back to this video the next time I lose something in my system!

  • Thank you, even after using Linux for 10 years and trying to puzzle out man pages (which are complete, detailed, factual, and often utterly useless), I’d given up on finding via terminal (except for executables when I can use whereis ) because I never got the command parameters right I’d either get no result, or the entire disk volume listed!

  • Linus команда grep поиск фрагмента текста в файле (файлах).

    #!/bin/bash
    # grep поиск фрагмента в файле (файлах)

    # 1:12 поиск фрагмента в файле
    grep ‘MyVideos’ text_file

    # 1:38 поиск фрагмента во всех файлах текущей директории
    grep ‘MyVideos’./*

    # 2:21 проверка числа вхождений в файлы текущей директории
    grep -с ‘MyVideos’./*

    # 3:06 поиск фрагмента без учёта регистра
    grep -i ‘myvideos’./*

    # 4:28 поиск по содержимому файла
    grep -f ttt./*

    # перенаправление потока
    ls -l../ | grep -f ttt

  • Привет Кирилл, как ты?
    Могу ли я быть наглым и попросить тебя, если у тебя есть на это время, создать ролик по теме 110.3 Securing data with encryption?
    Я собираюсь в понедельник сдавать экзамен 102 и как на зло ничего из этой темы не могу понять.
    В любом случае спасибо заранее и хорошего дня )))

  • Hey Chris,

    From a Terminal beginners perspective i feel like you went really really fast in this video, id like to know what every bit of the command does and have time to comprehend that personally, like really overexplaining things would be helpful for it to stick in. Overall though its a wellmade video with great info, thanks:)

  • May I ask what distro you are using for these examples? It has always been my experience that you must quote wildcarded file names to prevent the shell from expanding the wildcard (which produces unexpected results and/or errors) and allows find itself to operate on the wildcards. Are you using as the starting directory because you are limiting the search to your home directory? Starting with returns absolute path names relative to your home directory, starting the path name with / returns absolute path names relative to /, starting with dot (.) returns relative path names relative to current directory. This is how I learned to use find (-print is technically correct but redundant in later versions of find.)
    find all files in my home directory that start with the string ‘media’:
    cd; find. -name ‘media*’ -print
    find /home/user -name ‘media*’ -print
    find -name ‘media*’ -print
    find all files in my home directory that contain the string ‘media’ (use of grep is not necessary and also forks additional processes):
    cd; find. -name ‘*media*’ -print
    find all files in the file system that contain the string ‘media’ (you will be restricted from certain directories as an ordinary user):
    cd /; find. -name ‘*media*’ -print
    find / -name ‘*media*’ -print

    If any part of my comment is incorrect or inappropriate, I apologize in advance.

    Oops, to be clear… the strings apply only to the actual file name and not to the content of the file.

  • Скажите пожалуйста, как просто найти нужный файл без всей этой мороки, как скажем в Ворд, просто пишешь нужное слово и запускаешь поисковик, а через несколько секунд, появляются все документы, содержащие искомое слвово? Спасибо.

  • Not relative to this video but have a couple of Linux questions.

    I am planning on rooting my Samsung Galaxy Tab E tablet and was wondering what Linux should I put on it (or should I keep the default and just get rid of the bloatwear)?

    Also, when my daughter buys her aunt’s laptop, I shall be having fun with her Chromebook and putting Linux on it. I was raised on computers and know basic programming (the logic behind programming but not the languages per say), which Linux should I install (realize it is a Chromebook so no heavy gaming on it)?

  • Chris, you should have used ‘media*’ between quotes.
    If you had a file in your current directory named fi. ‘media.jpg’ then bash would have replaced your medi* with media.jpg and you would be looking only for that filename.
    If you had two filenames starting with media, bash would have replaced media* with those 2 names and the find command would have thrown an error.

    So I guess it is time for you to make a video talking about wildcards and globbing 😉

Случайный совет