./DUMB_TERMINAL_BLOG/

// Programming insights from the command line

It’s progress at least

Paste this into progress_demo.sh

#!/bin/bash

# ANSI color codes
CYAN='\033[0;36m'
RESET='\033[0m'

# Pure progress bar function - takes current count and total
show_progress() {
    local current=$1
    local total=$2
    local bar_length=${3:-50}  # Optional bar length, defaults to 50
    
    # Calculate progress
    local progress=$((current * bar_length / total))
    local percentage=$((current * 100 / total))
    
    # Build progress bar
    local bar=""
    for ((j=0; j<bar_length; j++)); do
        if [ $j -lt $progress ]; then
            bar+="█"
        else
            bar+="░"
        fi
    done
    
    # Print progress bar with \r to overwrite the line
    printf "\r${CYAN}[%s] %3d%%${RESET}" "$bar" "$percentage"
}

# Demo function that uses the progress bar
demo_progress() {
    local duration=${1:-3}
    local steps=${2:-100}
    
    echo "Starting progress demo..."
    
    for ((i=0; i<=steps; i++)); do
        show_progress "$i" "$steps"
        sleep $(awk "BEGIN {print $duration / $steps}")
    done
    
    # New line after completion
    echo ""
    echo "Progress complete!"
}

# Example of using the progress bar for a file processing simulation
demo_file_processing() {
    local files=("file1.txt" "file2.txt" "file3.txt" "file4.txt" "file5.txt")
    local total=${#files[@]}
    
    echo "Processing files..."
    
    for ((i=0; i<total; i++)); do
        show_progress "$((i+1))" "$total"
        # Simulate processing time
        sleep 0.5
    done
    
    echo ""
    echo "File processing complete!"
}

# Main execution
main() {
    local demo_type=${1:-"time"}  # "time" or "files"
    
    case $demo_type in
        "time")
            local duration=${2:-3}
            echo "Demo: Time-based Progress Bar"
            echo "Duration: ${duration} seconds"
            echo ""
            demo_progress "$duration"
            ;;
        "files")
            echo "Demo: File Processing Progress Bar"
            echo ""
            demo_file_processing
            ;;
        *)
            echo "Usage: $0 [time|files] [duration_for_time_demo]"
            echo "Examples:"
            echo "  $0 time 5    # 5-second time demo"
            echo "  $0 files     # file processing demo"
            exit 1
            ;;
    esac
}

# Run the demo
main "$@"

# Time-based demo (default)
./progress_demo.sh time 5

# File processing demo
./progress_demo.sh files

GREP_SEARCH

$ find /home1/nbfgusmy/public_html/website_a7bbcdc7/ -type f -name ".php" -o -name ".md" | xargs grep -n
-i : ignore case -r : recursive search -n : show line numbers --include="*.{php,js,css,md}"
Establishing connection to Dumb Terminal mainframe...