"리눅스 언어별 스크립트 파일 실행"의 두 판 사이의 차이

잔글 (로봇: 자동으로 텍스트 교체 (-<source lang='dos'> +<source lang='cli'>))
7번째 줄: 7번째 줄:
==Awk==
==Awk==
[[category: Awk]]
[[category: Awk]]
<source lang='dos'>
<source lang='cli'>
[root@jmnote ~]# cat hello.awk
[root@jmnote ~]# cat hello.awk
#!/bin/awk -f
#!/bin/awk -f
17번째 줄: 17번째 줄:
==Bash==
==Bash==
[[category: Bash]]
[[category: Bash]]
<source lang='dos'>
<source lang='cli'>
[root@jmnote ~]# cat hello.sh
[root@jmnote ~]# cat hello.sh
#!/bin/bash
#!/bin/bash
27번째 줄: 27번째 줄:
==Lua==
==Lua==
[[category: Lua]]
[[category: Lua]]
<source lang='dos'>
<source lang='cli'>
[root@jmnote ~]# cat hello.lua
[root@jmnote ~]# cat hello.lua
#!/usr/bin/lua
#!/usr/bin/lua
37번째 줄: 37번째 줄:
==Perl==
==Perl==
[[category: Perl]]
[[category: Perl]]
<source lang='dos'>
<source lang='cli'>
[root@jmnote ~]# cat hello.pl
[root@jmnote ~]# cat hello.pl
#!/usr/bin/perl
#!/usr/bin/perl
47번째 줄: 47번째 줄:
==PHP==
==PHP==
[[category: PHP]]
[[category: PHP]]
<source lang='dos'>
<source lang='cli'>
[root@jmnote ~]# cat hello.php
[root@jmnote ~]# cat hello.php
#!/usr/bin/php
#!/usr/bin/php
58번째 줄: 58번째 줄:
==Python==
==Python==
[[category: Python]]
[[category: Python]]
<source lang='dos'>
<source lang='cli'>
[root@jmnote ~]# cat hello.py
[root@jmnote ~]# cat hello.py
#!/usr/bin/python
#!/usr/bin/python
68번째 줄: 68번째 줄:
==Ruby==
==Ruby==
[[category: Ruby]]
[[category: Ruby]]
<source lang='dos'>
<source lang='cli'>
[root@jmnote ~]# cat hello.rb
[root@jmnote ~]# cat hello.rb
#!/usr/bin/ruby
#!/usr/bin/ruby

2015년 2월 6일 (금) 04:15 판

1 개요

리눅스 쉘에서 스크립트 파일 실행
리눅스 쉘에서 파일 실행
  • #!에서 스크립트의 실행환경을 설정
  • 실행권한 퍼미션이 주어져야 함

2 Awk

[root@jmnote ~]# cat hello.awk
#!/bin/awk -f
{print "Hello, world!"}
[root@jmnote ~]# echo '' | ./hello.awk
Hello, world!

3 Bash

[root@jmnote ~]# cat hello.sh
#!/bin/bash
echo 'Hello, world!'
[root@jmnote ~]# ./hello.sh
Hello, world!

4 Lua

[root@jmnote ~]# cat hello.lua
#!/usr/bin/lua
print "Hello, world!"
[root@jmnote ~]# ./hello.lua 
Hello, world!

5 Perl

[root@jmnote ~]# cat hello.pl
#!/usr/bin/perl
print "Hello, world!\n"
[root@jmnote ~]# ./hello.pl
Hello, world!

6 PHP

[root@jmnote ~]# cat hello.php
#!/usr/bin/php
<?php
echo "Hello, world!\n";
[root@jmnote ~]# ./hello.php
Hello, world!

7 Python

[root@jmnote ~]# cat hello.py
#!/usr/bin/python
print "Hello, world!"
[root@jmnote ~]# ./hello.py
Hello, world!

8 Ruby

[root@jmnote ~]# cat hello.rb
#!/usr/bin/ruby
puts "Hello, world!"
[root@jmnote ~]# ./hello.rb
Hello, world!

9 같이 보기