Thursday, 15 February 2024

Oracle Linux Commands - part 2/4

 

In this post i am going to share few of the oracle Linux commands .. i have posted total 4 post for Complete Linux high level commands .


part 1 : https://anjaniappsdba.blogspot.com/2023/09/oracle-linux-commands-part-14.html


this is  part 2 .. in my next post will share part 3 commands 


In Linux Searching Commands

=====================

 locate filename>> to search entire file system for given file name

 find / -name filename>> to search entire / file system for given file

name

 find . –name filename>> it searches the file in current directory

 find . –iname filename>> it searches the file in current directory with

ignore the case sensitive

 find / -type f –name filename>> it searches the file in the file system of /

 find / -type d –name dirname >> it searches the directory in the file

system of /

 find / -type f –name filename –exec rm –rf {}\; >>to find the file and

remove that file

 find / -type f –empty >> it display the empty file

 find / -type d –empty >> it display the empty directories

 find / -mtime 50 >> to be find the last 50 days modified files

 find / -mtime +50 –mtime -100 >> to be find the last 50 days to 100days

modified files.

 find / -mmin -60>> it displayes the last one hour modified file

 find / -cmin -60>> it displayes the last one hour changed file

 find / -atime 50>> it displayes the last 50 days accessed file

 find / -size 50M >> it displayes the 50 mb files.

 find / -size +50M –size -100M >> it displayes the 50 mb to 100mb files.

 Find / -size +100M –exec rm –rf {} \; >> it finds the 100 mb files and

delete the files

Find the largest file in the current & sub
directories

find . -type f -exec ls -s {} \; | sort -n -r | head -1

Find the smallest file in the current directory and sub

directories

find . -type f -exec ls -s {} \; | sort -n -r | tail -1

or

find . -type f -exec ls -s {} \; | sort -n | head -1

Find the files which are created between two files

find . -cnewer f1 -and ! -cnewer f2

Find the permissions of the files which contain the name

"java"?

find -name "*java*"|xargs ls -l

Alternate method is

find -name "*java*" -exec ls -l {} \;

Find the files which have the name "java" in it and then display
only the files which have "class" word in them?

find -name "*java*" -exec grep -H class {} \;

Remove files which contain the name "java".

find -name "*java*" -exec rm -r {} \;

Find & Copy Commands :


find . -type f -name "*.mp3" -exec cp {} /tmp/MusicFiles \;

# cp *.mp3 files to /tmp/MusicFiles

How to Copy one file to Many directories 


find dir1 dir2 dir3 dir4 -type d -exec cp header.shtml {} \;

# copy the file header.shtml to those dirs

Find and Delete Files in the Linux Command Line

find . -name "*.bak" -delete

Find files with different file extensions

find . -type f \( -name "*.c" -o -name "*.sh" \)

find . -iname foo

If you're just interested in directories, search like this:

find . -iname foo -type d

And if you're just looking for files, search like this:

find . -iname foo -type f



Thanks,

Srini

No comments:

Post a Comment


No one has ever become poor by giving