How to delete files containing a character or number/digit in their filename on Linux or Unix

You can delete files containing a character or number/digit in their filename using the find command and the rm command. Here is an example to delete all files containing a digit in their filename:   find . -type f -name “*[0-9]*” -delete Explanation: find .: Find files in the current directory. -type f: Find only … Read more

How to install route command on CentOS / RHEL 7

The route command is already installed and available on most Linux distributions, including CentOS and RHEL 7. To verify if it’s installed on your system, you can run the following command in the terminal:   route –version If the output shows the version of the route command, it means it’s already installed on your system. … Read more

How to remove non empty Directory in Linux

To remove a non-empty directory in Linux, you can use the “rm” command with the “-r” option for recursive deletion:   rm -r <directory_name> For example:   rm -r /path/to/non_empty_directory This will remove all files and subdirectories within the target directory. Be careful when using the “-r” option, as it can permanently delete large amounts … Read more

How to find and replace text/IP address with Ansible

To find and replace text/IP address with Ansible, you can use the replace module. Here’s an example of how you can use it in a playbook:   – name: Replace text in file replace: path: /path/to/file regexp: ‘old_text’ replace: ‘new_text’ – name: Replace IP address in file replace: path: /path/to/file regexp: ‘old_ip’ replace: ‘new_ip’ In … Read more