Created
August 1, 2018 16:44
-
-
Save shtrih/038a753fa6ec3394d036eeddd6457f15 to your computer and use it in GitHub Desktop.
Bash loop command over arguments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# usage: ./loop.sh "command name" arg1 arg2 2>&1 | tee loop.log | |
for i; do | |
if [ "$1" = "$i" ]; then | |
continue; | |
fi | |
echo "\n\n" $1 "$i"; | |
VAR=$($1 "$i"); | |
echo "$VAR"; | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run command «php artisan index:links -vvv» with arguments | |
user@user$> ./loop.sh "php artisan index:links -vvv" 103045617 90087612 2>&1 | tee loop.log | |
# loop.log content: | |
php artisan index:links -vvv 103045617 | |
Indexing document "103045617" | |
Found 43 links | |
Successfully indexed document "103045617" | |
php artisan index:links -vvv 90087612 | |
Indexing document "90087612" | |
[01-Aug-2018 16:41:16 UTC] [2018-08-01 16:41:16] local.WARNING: Rule not found "20180521" | |
Found 11 links | |
Successfully indexed document "90087612" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment