Redirect all lines of code to the same file in a single line
1
vote
2
answers
65
views
I have the following command set used to update all my WordPress sites in my CentOs shared-hosting partition on my hosting provider's platform (via daily cron).
The
wp
commands inside the pushd-popd
set, are of the WP-CLI program, which is a Bash extension used for various shell-level actions on WordPress websites.
for dir in public_html/*/; do
if pushd "$dir"; then
wp plugin update --all
wp core update
wp language core update
wp theme update --all
popd
fi
done
The directory public_html
is the directory in which all website directories are located (each website usually has a database and a main file directory).
Given that public_html
has some directories **which are not** WordPress website directories, than, WP-CLI would return errors regarding them.
To prevent these errors, I assume I could do:
for dir in public_html/*/; do
if pushd "$dir"; then
wp plugin update --all 2>myErrors.txt
wp core update 2>myErrors.txt
wp language core update 2>myErrors.txt
wp theme update --all 2>myErrors.txt
popd
fi
done
Instead writing 2>myErrors.txt
four times (or more), is there a way to ensure all errors whatsoever, from every command, will go to the same file, in one line?
Asked by Arcticooling
(1 rep)
May 29, 2018, 02:08 PM
Last activity: May 29, 2018, 04:05 PM
Last activity: May 29, 2018, 04:05 PM