Main Menu

Search

Showing posts with label linux find commands. Show all posts
Showing posts with label linux find commands. Show all posts

LINUX: FIND COMMAND TO PRINT TIME STAMPS OF THE FILE DURING SEARCH

Following is command to use.

find / -name <file name> -printf '%Tc %p\n' 2>/dev/null

Following is sample output of above command.

# find / -name repomd.xml -printf '%Tc %p\n' 2>/dev/null 
Wed 25 Mar 2015 11:28:49 AM PDT /root/repodata/repomd.xml 

 


Products to which Article Applies

All Linux Operating System 

Search Keywords: linux unix find finding file files commands time stamp timestamp date print printing command search searching

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO FIND FILES / DIRECTORIES OWNED BY PARTICULAR USER AND CHANGE USER GROUP OWNERSHIP TO ANOTHER USER

Following is command to use. Below command searches for all files owned by root user in current directory and changes user group ownership to appuser:appgroup

find . -user root -exec chown appuser:appgroup {} \;

 


Products to which Article Applies

All Linux Operating System 

Search Keywords: linux unix find finding file owned own particular user files owner super user all command commands change changing ownership different another other directory directories

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO FIND ALL FILES AND FOLDERS IN A DIRECTORY WHICH ARE OWNED BY A PARTICULAR USER

Following is command to use. Replace appuser with the username (you want to list files owned).

find . -user appuser

Following is sample output of above command.

 Sample Output

 


Products to which Article Applies

All Linux Operating System 

Search Keywords: linux unix find finding file owned own particular user files owner super user all command commands

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO FIND ALL FILES AND FOLDERS IN A DIRECTORY WHICH ARE OWNED BY ROOT USER

Following are commands to use for finding all files owned by root user in particular directory.

find . -user root 
 
find . -user 0 

 


Products to which Article Applies

All Linux Operating System 

Search Keywords: linux unix find finding file owned own root user files owner super user all command commands

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO LIST USER GROUP OF ALL SUB DIRECTORIES IN A DIRECTORY 

Following is command to use.

find -printf "%u %g %h/%d\n" | sort 

Following is sample output of above command.

 root root ./0 
root root ./1 
root root ./1 
root root ./1 
root root ./1 
root root ./1 
root root ./1 

 


Products to which Article Applies

All Linux Operating Systems 

Search Keywords: linux unix find finding user users group groups list listing in particular directory directories command commands

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO LIST USER AND GROUPS OF ALL FILES IN A DIRECTORY 

Following is command to use.

find -printf "%u %g %h/%f\n" | sort

Following is sample output of above command.

 root root ./testdir 
root root ./testdir/test1 
root root ./testdir/testing 
root root ./testdir/testing/1 
root root ./testdir/testing/1/1 
root root ./testdir/testing/1/1/2.txt 
root root ./testdir/test.txt 

 


Products to which Article Applies

All Linux Operating Systems 

Search Keywords: linux unix find finding user users group groups list listing in particular directory directories command commands

Article Author: Tarun Boyella

 

LINUX: FIND COMMANDS TO FIND A FILE AND CAT THE CONTENTS OF THE FILE

Following is command to use.Below command searches for testfile in current directory and cat its output and display it

find . -name test file -exec cat {} \;

 


Products to which Article Applies

All Linux Operating Systems 

Search Keywords: linux unix find finding file files cat display print printing  particular command commands output content displaying

Article Author: Tarun Boyella

 

LINUX: FIND COMMANDS TO FIND A FILE AND COPY AND BACK IT UP IN ANOTHER DIRECTORY

Following is command to use. Below command finds showvnics file under /app1 directory and backs it up /app2 directory with .bckp extension.

find /app1 -name showvnics -exec cp {} /app2/{}.bkup \;

 


Products to which Article Applies

All Linux Operating Systems 

Search Keywords: find finding command commands unix linux file files backup back up backing backed another other directory directories copy copying copied

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO FIND ALL FILES IN A DIRECTORY AND COPY THEM TO ANOTHER DIRECTORY / LOCATION

Following is command to use. Below command copies all files under /app1 directory to /app2 directory.

find /app1 -type f -exec cp {} /app2 \; 

 


Products to which Article Applies

All Linux Operating Systems 

Search Keywords: linux unix file files copy copying copies all directory directories particular another other find finding location place

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO IGNORE CASE WHEN SEARCHING FOR FILENAMES

Following is command to use.

find . -iname <filename>

 


Products to which Article Applies

All Linux Operating Systems 

Search Keywords: find finding command commands search searching ignore case lower upper ignoring capital small sensitve insensitive linux unix

Article Author: Tarun Boyella

 

LINUX: FIND COMMAND TO SEARCH MULTIPLE FILENAME PATTERNS

Below is command to use.

find . -name “<filename1>" -o -name "<filename2>" -o -name "<filename>" …… -o -name "<filenameN>"

Sample Output.

 $ find . -name "emoc*" -o -name "cacao*" 
 
./opscenter/config/etc/opt/sun/cacao2 
./opscenter/config/etc/opt/sun/cacao2/instances/default/private/cacao.properties 
./opscenter/config/etc/opt/sun/cacao2/instances/scn-proxy/private/cacao.properties 
./opscenter/logs/var/log/emoc_template_pccheck.log.1 
./opscenter/logs/var/log/emoc_template_pccheck.log.10 

 


Products to which Article Applies

All Linux Operating Systems 

Search Keywords: Linux UNIX multiple search searching command commands find finding more file files pattern patterns 

 

Article Author: Tarun Boyella