Skip to content

Instantly share code, notes, and snippets.

@donglixp
Created January 3, 2025 12:35
Show Gist options
  • Save donglixp/f90ea8ee53ac4f62d8381d230b04da5d to your computer and use it in GitHub Desktop.
Save donglixp/f90ea8ee53ac4f62d8381d230b04da5d to your computer and use it in GitHub Desktop.
#!/bin/bash
# Name of the input file containing commands
input_file="cmd_lines.sh"
# Read the input file line by line
while IFS= read -r line; do
# Skip empty lines and comments
if [[ -z "$line" ]] || [[ "$line" =~ ^# ]]; then
continue
fi
# Create a new screen session and execute the command
screen -dmS "line-$(date +%s%N)" bash -c "$line"
done < "$input_file"
echo "Commands launched in separate screens."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment