Skip to content
The Chat Archive
Mistralmistral-medium· Mistral AI Arena Human Preference 55K

What are some useful bash scripts

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Perplexitypplx-70b-online’s answer.
  1. User

    What are some useful bash scripts

  2. Assistant

    Here are some examples of useful bash scripts:

    1. File backup script: This script will backup files from one directory to another, optionally compressing them and keeping multiple versions.
    #!/bin/bash
    
    # Backup script
    
    # Define source and target directories
    src="/path/to/source"
    dst="/path/to/backup"
    
    # Define number of backup versions to keep
    versions=5
    
    # Create target directory if it doesn't exist
    mkdir -p "$dst"
    
    # Find and remove old backup versions
    find "$dst" -type f -name "backup-*" -mtime +$[(versions\*86400)] -exec rm {} \;
    
    # Create new backup
    tar czf "$dst/backup-$(date +%Y-%m-%d-%H-%M-%S).tar.gz" "$src"
    
    1. Disk usage script: This script will display the disk usage of all the directories in the current directory in a human-readable format.
    #!/bin/bash
    
    # Disk usage script
    
    # Define directory to check
    dir="."
    
    # Print disk usage for each directory
    du -sh "$dir"/*/ | sort -h
    
    1. Network monitoring script: This script will continuously monitor the network connection and print the current upload and download speeds.
    #!/bin/bash
    
    # Network monitoring script
    
    # Define interface to monitor
    interface="eth0"
    
    # Print network usage every second
    while true; do
      rx=$(cat /proc/net/dev | grep "$interface" | tr -s ' ' | cut -d' ' -f3)
      tx=$(cat /proc/net/dev | grep "$interface" | tr -s ' ' | cut -d' ' -f11)
      echo "RX: $rx bytes/sec  TX: $tx bytes/sec"
      sleep 1
      rx=$((rx - $(cat /proc/net/dev | grep "$interface" | tr -s ' ' | cut -d' ' -f3)))
      tx=$((tx - $(cat /proc/net/dev | grep "$interface" | tr -s ' ' | cut -d' ' -f11)))
    done
    
    1. System information script: This script will display various system information such as the operating system, kernel version, CPU and memory usage, and disk space.
    #!/bin/bash
    
    # System information script
    
    # Print operating system information
    echo "Operating System:"
    uname -a
    
    # Print kernel version
    echo "Kernel Version:"
    uname -r
    
    # Print CPU information
    echo "CPU Information:"
    lscpu
    
    # Print memory usage
    echo "Memory Usage:"
    free -h
    
    # Print disk usage
    echo "Disk Usage:"
    df -h
    

    I hope you find these examples helpful! Let me know if you have any questions.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.