shellscript에 대하여
TRANSCRIPT
Shellscript에�대하여
Luavis/sherlock.py
Intro
Lightning�Talk
Intro
Intro
오랜만에�해보는�언어�공부
Intro
Shellscript
A�shell�script�is�a�computer�program�designed�to�be�run�by�the�Unix�shell,�a�command-line�interpreter.
Ksh Bashsince�1987since�1983
History
Assignment
a=10
b=‘10’
b=“10”
local�b=“10”
export�b=10
b=Hello\�World
b=“Hello�World”
Array
a=(1�2�3�4)
a=(1�“2”�“3”�“4”)
다중배열�불가
Array
a=(1�2�3�4)
a=(1�“2”�“3”�“4”)
다중배열�불가
Array
array_name=("value�1"�"value�2"�"value�3")���echo�"array_name[0]�����=�${array_name[0]}"�echo�"array_name[2]�����=�${array_name[2]}"��echo�"array_name[*]�����=�${array_name[*]}"��echo�"array_name[@]�����=�${array_name[@]}"��echo�"array_name�index��=�${!array_name[@]}"�echo�"array_name�size���=�${#array_name[@]}"�echo�"array_name[0]�size=�${#array_name[0]}"
Array
array_name[0]�����=�value�1�array_name[2]�����=�value�3�array_name[*]�����=�value�1�value�2�value�3�array_name[@]�����=�value�1�value�2�value�3�array_name�index��=�0�1�2�array_name�size���=�3�array_name[0]�size=�7
String�concat
Numeric�expression
a=10�b=20�
c=$(($a�+�$b))�c=`expr�$a�+�$b`
If�statement
if�[�<case>�];�then�<statements>�
elif�[�<case>�];�then�<statements>�
else�<statements>�
fi
Comparison�operator�(numeric)
$A�-gt�$B�
$A�-lt�$B�
$A�-ge�$B�
$A�-le�$B�
$A�-eq�$B�
$A�-ne�$B
A가�B보가�크다������
A가�B보다�작다.�
A가�B보다�크거나�같다.������
A가�B보다�작거나�같다.�
A와�B가�같다.������
A와�B가�다르다.
"string1"�=�"string2"�
"string1"�!�"string2"�
-z�"string"�
-n�"string"
두�문자열이�같은�경우�
두�문자열이�다른�경우�
문자열의�길이가�0인�경우�
문자열의�길이가�0이�아닌경우
Comparison�operator�(string)
Logical�operator
-a�:�and�-o�:�or
If�statement�example
a=20�
if�[�$a�-gt�10�-a�$a�-lt�20�];�then�����echo�"10과�20�사이"�elif�[�$a�-gt�20�-a�$a�-lt�30�];�then�����echo�"20과�30�사이"�else�����echo�"아몰랑"�fi
For�loop�statement
max=10�for�((�i=1;�i�<=�$max;�i++�))�do�����echo�"$i"�done
for�i�in�{{1..10}}�do�����echo�"$i"�done
for�i�in�1�2�3�4�5�6�7�8�9�10�do�����echo�"$i"�done
Switch-case�statement
case�<variable>�in�<patter1>)�����<statements>�����<statements>;;�<pattern2>)�����<statements>;;�����<statements>;;�*)�����<statements>�����<statements>;;�esac
Function
function�two_sum_func()�{����sum=$(($1�+�$2))�����return�$sum�}�
two_sum_func�result=$?
Function
Return은�숫자만�가능
Function
result=“”�function�get_hello_world()�{���result=“Hello�World”�}�
get_hello_world�echo�“$result”
사용�예
Install�script�
Build�script�
Dotfiles
이�언어를�조금만�써보면�느끼는�점
♚♚Sherlock☆py♚♚�다운시$$당신도�스크립트�마스터
☜☜뒷면100%가능※�♜손쉬운�
파이썬♜편한�사용법�¥�개발참여¥기회@@@�즉시이동�https://pypi.python.org/pypi/sherlock.py
1. 일단�문법이�파이썬
2. 자주�사용하는�구문�패키징
3. unix-shell뿐만�아니라windows�batch�파일까지
Sherlock.py는..
감사합니다.
Reference
* http://www.dreamy.pe.kr/zbxe/CodeClip/3765734�* https://wikipedia.org�* http://blog.redjini.com/282�
QnA