Bash Clear DNS Cache

In Bash, you can clear the DNS cache by flushing the system resolver cache. Here are the steps to clear the DNS cache in Bash: Open a terminal window and type the following command to clear the cache: sudo systemd-resolve –flush-caches This command will flush the DNS cache and any other caches that may be … Read more

Applescript: Run or Call a Shell Script

To run or call a shell script from AppleScript, you can use the do shell script command. Here’s an example: set myScriptPath to “/path/to/my/script.sh” do shell script myScriptPath In this example, the myScriptPath variable contains the path to the shell script that you want to run. The do shell script command then executes the script. … Read more

How To: Rename A File In Bash

To rename a file in Bash, you can use the mv command, which is used to move and rename files. Here’s the basic syntax: mv old_filename new_filename For example, to rename a file named “file.txt” to “new_file.txt”, you can use the following command: mv file.txt new_file.txt This will rename the file “file.txt” to “new_file.txt” in … Read more

Bash Iterate Array Examples

Functions in Bash shell scripts allow you to group a set of commands together and call them from multiple places in your script. Here are some examples of how to define and call Bash shell script functions: Define a function that prints a message to the console: function my_function { echo “Hello, World!” } You … Read more

Bash Shell Script Function Examples

In Bash, you can iterate over an array in several ways. Here are some examples: Iterate over an array using a for loop: my_array=(apple banana cherry) for i in “${my_array[@]}” do echo “$i” done This will loop through each element in the my_array array and print it to the console. Iterate over an array using … Read more

Apache: Graceful Server Reboot From Shell

To gracefully reboot the Apache server from the shell in Linux or Unix-based systems, you can use the apachectl command with the -k graceful option. Here are the steps: Open a terminal window on your Linux or Unix-based system. Switch to the root user or use the sudo command to run the following command: apachectl … Read more