How to find both files and folders that are used in some process? [duplicate] - linux

This question already has answers here:
Delete files older than 10 days using shell script in Unix [duplicate]
(3 answers)
Closed 7 years ago.
I want to delete files and folders older than 15 days.
But Before deletion I want to check that those file and folders shouldn't use anywhere. How can i do that ?
is ps -ef works for this ?

Using the find command:
find /path/to/folder -type f -mtime +15 -delete

Related

How to write script displaying all subdirectories in the location [duplicate]

This question already has answers here:
List sub-directories with ls [closed]
(3 answers)
Closed 3 years ago.
I need help. How to write script displaying all subdirectories in the location. I've got something like that:
ls -al | grep ^d
but it only works in the home directory
find(1) may be a better choice here:
find . -type d
which would list all directories from the current directory and all subdirectories.

How do AWK, grep and Find commands differ from each other, sice all these three command looks for a specific phrase in text file or directory? [duplicate]

This question already has answers here:
Find all files with name containing string [closed]
(8 answers)
Closed 5 years ago.
I just want to know how AWK, grep and find command differ from each other in terms of functionalities and which command to use when?
The command would be
find . -type d -name '*word*'

Delete files older than 7 days in perl [duplicate]

This question already has answers here:
delete folders older than 12 hours in perl
(3 answers)
Closed 5 years ago.
How to delete files from directories who are older than certain days (7 days) OR files who was created on any certain date?
Be careful with special file names (spaces, quotes) when piping to rm.
There is a safe alternative - the -delete option:
find /path/to/directory/ -mindepth 1 -mtime +5 -delete
That's it, no separate rm call and you don't need to worry about file names.
Replace -delete with -depth -print to test this command before you run it (-delete implies -depth).

Bash - find files older than X minutes and move them [duplicate]

This question already has answers here:
find files older than X days in bash and delete
(3 answers)
Closed 7 years ago.
I need to create a bash script and put in CRON - on linux.
I need to loop through or just find all files in directory DIR_A and if files are older than, for example, 10 minutes, move them to directory DIR_B.
Any ideas? Thanks!
If anyone else needs it:
find DIR_A -maxdepth 1 -type f -mmin +10 -exec mv "{}" DIR_B/ \

Bash: How to list only files with read permissions? [duplicate]

This question already has answers here:
Find all writable files in the current directory
(11 answers)
Closed 7 years ago.
How can I list all the files with read permissions on current directory ?
find -maxdepth 1 -type f -perm xxx
Where xxx indicate the file permission on your targer file, according to this question.

Resources