Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Script to Run Multiple Tail Commands in Different Command Line Tabs
#!/bin/bash
# Blog Post: http://joaoperibeiro.com/command-line-script-to-launch-multiple-tabs/
# Array of commands to run in different tabs
commands=(
'tail -f /var/log/apache2/access.log'
'tail -f /var/log/apache2/error.log'
'tail -f /usr/local/var/postgres/server.log'
)
# Build final command with all the tabs to launch
set finalCommand=""
for (( i = 0; i < ${#commands[@]}; i++ )); do
export finalCommand+="--tab -e 'bash -c \"${commands[$i]}\"' "
done
# Run the final command
eval "gnome-terminal "$finalCommand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment