LoginSignup
0
1

More than 5 years have passed since last update.

bash/ヒアドキュメント

Last updated at Posted at 2019-03-25

シェル内でヒアドキュメント

cat << _EOT_ > /tmp/sample.sql
SELECT
  table_schema,
  table_name,
  current_timestamp as wtime
from
  information_schema.tables
where
  table_schema = 'information_schema' ;
_EOT_

パイプで実行する例

cat /tmp/sample.sql | mysql -u root -p

リダイレクトで実行する例

mysql -u root -p < /tmp/sample.sql

コマンド入力をヒアドキュメント化

mysql -u root -p << _EOT_
SELECT
  table_schema,
  table_name,
  current_timestamp as wtime
from
  information_schema.tables
where
  table_schema = 'information_schema' ;
_EOT_
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1