![]() This will search the file for the word “Linux” and if it is found, it will return the line that contains it. Another way to check if a file name contains Linux is to use the grep command. This will give you the file type and if the file is a text file, it will also tell you if the file is a Linux file. The first way is to use the file command. ![]() Resources: Banner images from Office illustrations by Storyset and Canva.There are a few ways that you can check if a file name contains Linux. In this article, we have studied the find command in detail and learned how to search files by name, type, size and modification time. ![]() The shared script is very useful in archiving and removing logs. As we do not want the shell to interpret the semicolon, we escape it with \. # Script to move from logs older than 7 days to backup logs path: /app/backup_logs/ESB0*įind /logs/esb01/audit -name "*.tar.gz" -mtime 7 -exec mv is the placeholder which holds the results of the command. We can create a script and schedule it with cron. From there, it deletes log files older that older than 30 days. Let's say we want to create a script that moves log files older than 7 days to a backup path. We can combine find with rm or mv to create meaningful bash scripts that can be automated. Practical examples of find with bash scripts ![]() type f -name ".*" -mtime 10 Here we have files that were modified more than 10 days ago. Let's apply an example in my home directory.
0 Comments
Leave a Reply. |