How to make an input redirect (equivalent to "<" on Linux) with Powershell?

Asked

Viewed 138 times

2

On Linux, when we want to do an output redirect, we use the symbol >.

 echo "Olá mundo" > Hello.txt

I did the above test on Powershell and got the same result.

It turns out that when I needed to import an SQL via command line, I couldn’t do the same thing I do on Linux by using "incoming redirect".

mysql -u root database_name < /caminho/para/o/arquivo.sql

How do I make this input redirect in Powershell?

2 answers

2


See if this settles for you:

Get-Content /caminho/para/o/arquivo.sql | mysql -u root database_name

I put in the Github for future reference.

You reverse the situation, take the content and send it to a command by doing a Piping.

1

Like alternative you could use your own mysql-client for this:

mysql -u root database_name
mysql> tabela /caminho/para/o/arquivo.sql
  • Interesting. Thank you for your reply, but in that case the intention was to ask a general question on the subject.

  • @Wallacemaxters by that same wrote "as alternative", I was going to reply something similar to that of Maniero, as it was faster I erased the beginning of my answer and left only the alternative part :P

Browser other questions tagged

You are not signed in. Login or sign up in order to post.