How to get list of all files from a directory (including its sub-directories) whose file name contains a specific string

Rudraprasad Pradhan

I want to retrieve the list of files from a directory & including its sub-directories too, Whose file name contains "message-" or "secure". I have tried with below commands , But they could not read files from its sub-directories.

find /u01 -maxdepth 1 -name "*message-*"

find . -name "*message-*"

find /u01 -type f -printf '%s %p\n' | sort -nr | head -20 | find  -maxdepth 1 -name "*message-*" -a -name "*secure*"

Can you please help on this...

Rudraprasad Pradhan

Below commands worked for me.

find /u01 -type f \( -name "*message*" -o -name "*secure*" \)   -type f -printf '%s %p\n'

To get top 20 largest file whose name contains those both string.

find /u01 -type f \( -name "*message*" -o -name "*secure*" \)   -type f -printf '%s %p\n' | sort -nr | head -20

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

From Dev

How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

From Dev

Setup a cron job to archive a directory and all its sub-directories including hidden files using tar

From Dev

Python 2.7 How to list files in a directory AND all sub directories?

From Dev

Get list of subdirectories which contain a file whose name contains a string

From Dev

List all regular files containing (in their name, directory or their content) a specific (sub)string

From Dev

Print a list of "full" relative paths of all the files present in a directory and in its sub-directories

From Dev

How can I move files by type recursively from a directory and its sub-directories to another directory?

From Dev

How can I move files by type recursively from a directory and its sub-directories to another directory?

From Dev

How to count occurrences of a string ex. "sometext" in multiple .gz files in a directory and its sub directories?

From Java

How to download HTTP directory with all files and sub-directories as they appear on the online files/folders list?

From Dev

How to check for executable files in a given directory and its sub-directories?

From Dev

list all c files in sub directories and their parent directory

From Dev

How to list directories, sub-directories and all files in php

From Dev

PHP : list files in directory and sub-directories into an XML file

From Dev

Delete all files in a directory whose name do not match a line in a file list

From Dev

How to remove all folders with a specific name recursively from all sub directories?

From Dev

How to recursively change files in directories whose name matches a string in Perl?

From Dev

List a directory but only if it contains sub-directories?

From Dev

How do I find the location of all files with a particular name whose content contains a particular string?

From Java

Drop columns whose name contains a specific string from pandas DataFrame

From Dev

How to move all files (excluding sub-directories) from one directory to another?

From Dev

How to delete all files in a directory, keeping sub-directories intact

From Dev

Copy files with certain extension from many nested sub-directories to a single directory and append to each copied file the name of the directory

From Dev

How to locate a file whose name (almost) matches its containing directory

From Dev

Error when uploading a directory to Dropbox including all files and sub-directories with Dropbox Python API

From Dev

Error when uploading a directory to Dropbox including all files and sub-directories with Dropbox Python API

From Dev

List main directory and its sub-directories using directory name property in power shell

From Dev

Create sub-directories and organize files by date from file name

Related Related

  1. 1

    How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

  2. 2

    How can I recursively find a directory by name and delete its contents (including all sub-directories and files) while keeping the directory itself?

  3. 3

    Setup a cron job to archive a directory and all its sub-directories including hidden files using tar

  4. 4

    Python 2.7 How to list files in a directory AND all sub directories?

  5. 5

    Get list of subdirectories which contain a file whose name contains a string

  6. 6

    List all regular files containing (in their name, directory or their content) a specific (sub)string

  7. 7

    Print a list of "full" relative paths of all the files present in a directory and in its sub-directories

  8. 8

    How can I move files by type recursively from a directory and its sub-directories to another directory?

  9. 9

    How can I move files by type recursively from a directory and its sub-directories to another directory?

  10. 10

    How to count occurrences of a string ex. "sometext" in multiple .gz files in a directory and its sub directories?

  11. 11

    How to download HTTP directory with all files and sub-directories as they appear on the online files/folders list?

  12. 12

    How to check for executable files in a given directory and its sub-directories?

  13. 13

    list all c files in sub directories and their parent directory

  14. 14

    How to list directories, sub-directories and all files in php

  15. 15

    PHP : list files in directory and sub-directories into an XML file

  16. 16

    Delete all files in a directory whose name do not match a line in a file list

  17. 17

    How to remove all folders with a specific name recursively from all sub directories?

  18. 18

    How to recursively change files in directories whose name matches a string in Perl?

  19. 19

    List a directory but only if it contains sub-directories?

  20. 20

    How do I find the location of all files with a particular name whose content contains a particular string?

  21. 21

    Drop columns whose name contains a specific string from pandas DataFrame

  22. 22

    How to move all files (excluding sub-directories) from one directory to another?

  23. 23

    How to delete all files in a directory, keeping sub-directories intact

  24. 24

    Copy files with certain extension from many nested sub-directories to a single directory and append to each copied file the name of the directory

  25. 25

    How to locate a file whose name (almost) matches its containing directory

  26. 26

    Error when uploading a directory to Dropbox including all files and sub-directories with Dropbox Python API

  27. 27

    Error when uploading a directory to Dropbox including all files and sub-directories with Dropbox Python API

  28. 28

    List main directory and its sub-directories using directory name property in power shell

  29. 29

    Create sub-directories and organize files by date from file name

HotTag

Archive