Reputation: 3323
I came across code that uses double >> syntax together with mysqldump. I'm wondering if this is valid mysqldump syntax. I did some google searches but wasn't able to find anything, so I'm thinking it's a typo:
mysqldump -h *** -u *** -p *** --single-transaction --no-data database_name table_name >> file_name
Can someone please confirm that it's invalid syntax or otherwise explain how >>
works compared to just the ordinary >
that I would expect to see here?
Upvotes: 1
Views: 51
Reputation: 108370
It's not a typo. You're right, that's not MySQL or mysqldump syntax. mysqldump utility writes output to STDOUT
.
The >>
is syntax for the shell.
That redirects STDOUT
to append to the specified file_name.
As a demonstration, consider:
echo "fee" > /tmp/mytest
echo "fi" >> /tmp/mytest
echo "fo" >> /tmp/mytest
echo "fum" >> /tmp/mytest
cat /tmp/mytest
Upvotes: 3