# Create the directory where the script will live $ mkdir -p "$HOME/.local/bin" # Save the script to that location, named 'geany-tail' $ cat > "$HOME/.local/bin/geany-tail" << \EOF > #!/usr/bin/env bash > set -e > temp_file=`mktemp geany-tail-XXXXXX` > trap 'rm -f "$temp_file"' EXIT > tail $@ > "$temp_file" > geany "$temp_file" > EOF # Make the script executable $ chmod +x "$HOME/.local/bin/geany-tail" # Add the script directory to $PATH environment variable $ cat >> "$HOME/.profile" << \EOF > > # Add local bin dir to PATH > PATH="$PATH:$HOME/.local/bin" > EOF # Source the updated ~/.profile to update environment variable $ . "$HOME/.profile" # Check the script is properly accessible $ which geany-tail # Using it, arguments are passed directly to 'tail' command # In this example, using the last 50 lines of the file 'syslog.txt' $ geany-tail -n 50 syslog.txt