#!/bin/bash local path="$1" # Check if the path is already in the environment file if ! grep -q "$path" /etc/environment; then # Get current PATH from environment file current_path=$(grep "^PATH=" /etc/environment | cut -d'"' -f2) if [ -z "$current_path" ]; then # If PATH doesn't exist in the file, create it echo "PATH=\"\$PATH:$path\"" >> /etc/environment else # Replace existing PATH line with updated one sed -i "s|^PATH=.*|PATH=\"$path:$current_path\"|" /etc/environment fi fi