1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

シェルスクリプト Hello World!

Posted at
echo
hello-world.sh
#!/bin/bash
echo 'Hello World!'
awk スクリプト

#!/usr/bin/awk -f で awk スクリプトになる
(-f オプションが必要)

hello-world-awk.sh
#!/usr/bin/awk -f
BEGIN {
  print "Hello world! by awk"
}
head コマンド

このスクリプトを実行すると、「/usr/bin/head -2 ./hello-world-tail.sh」が実行される

hello-world-head.sh
#!/usr/bin/head -2
Hello World! 1
Hello World! 2
Hello World! 3
出力
#!/usr/bin/head -2
Hello World! 1

即ち、”1行目のところに書いたコマンド(/usr/bin/head -2) が、スクリプトのファイル名(hello-world-head.sh)を引数に付けて実行されている”ということが分かる。

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?