#!/bin/bash # This is a comment echo "Starting Script..." # Define a variable FILE_NAME="backup.txt" # Create a file touch $FILE_NAME # List files and save to a report ls -l > $FILE_NAME echo "File list saved to $FILE_NAME" Use code with caution. Copied to clipboard 5. Steps to Create and Run a Script

Validate input: Ensure that necessary arguments are provided before running core logic.

Always use a ( #!/bin/bash ) to ensure the correct shell is used. Add comments ( # ) to explain complex logic.

grep (search), sed (stream editor), awk (data manipulation), cat (view content), cut , sort .

if-then-else , case statements for decision-making. Loops: for , while loops to repeat tasks. Input/Output Redirection & Pipes: > : Redirect output (overwrite file). >> : Append output.