Shell Script 의 기본
bash-4.1$ x=3
bash-4.1$ echo $x
3
bash-4.1$ echo "hello there"
hello there
bash-4.1$ echo 'hello there'
hello there
bash-4.1$ echo hello there
hello there
bash-4.1$ echo "the value of x: $x"
the value of x: 3
bash-4.1$ echo 'the value of x: $x'
the value of x: $x
bash-4.1$ echo 'I have $10000'
I have $10000
bash-4.1$ echo Today is `date`
Today is Wed Aug 6 12:50:46 EST 2014
bash-4.1$ echo "Today is `date`"
Today is Wed Aug 6 12:51:00 EST 2014
permission
bash-4.1$ ls -l
total 2
-rw-r--r--+ 1 11776352 Students 0 Jul 30 13:06 a.txt
-rw-r--r--+ 1 11776352 Students 0 Jul 30 13:06 c.txt
-rw-r--r--+ 1 11776352 Students 334 Aug 6 12:40 hello.txt
bash-4.1$ chmod 600 a.txt
bash-4.1$ ls -l
total 2
-rw-------+ 1 11776352 Students 0 Jul 30 13:06 a.txt
-rw-r--r--+ 1 11776352 Students 0 Jul 30 13:06 c.txt
-rw-r--r--+ 1 11776352 Students 334 Aug 6 12:40 hello.txt
bash-4.1$ chmod 644 a.txt
bash-4.1$ ls -l
total 2
-rw-r--r--+ 1 11776352 Students 0 Jul 30 13:06 a.txt
-rw-r--r--+ 1 11776352 Students 0 Jul 30 13:06 c.txt
-rw-r--r--+ 1 11776352 Students 334 Aug 6 12:40 hello.txt
first --- user (u)
second --- group (g)
third --- other (o)
0 000
1 001 * execute = 1
2 010 * write = 2
3 011
4 100 * read = 4
5 101
6 110
7 111
readable, writable, executable = 4+2+1 = 7 (rwx)
chmod 755 myfile
chmog o+x myfile
chmog o-x myfile
Script 실행
bash-4.1$ hello.sh
bash: hello.sh: command not found
bash-4.1$ pwd
/home/11776352/usp/2
bash-4.1$ /home/11776352/usp/2/hello.sh
hello world
bash-4.1$ cd ..
bash-4.1$ 2/hello.sh
hello world
bash-4.1$ cd 2/
bash-4.1$ ls
a.txt c.txt hello.sh hello.txt
bash-4.1$ ../2/hello.sh
hello world
bash-4.1$ ./hello.sh
hello world
Script 응용
'초짜 IT보이 서바이벌 스토리 > Unix-Linux' 카테고리의 다른 글
Unix [Linux] Shell Script 의 기본 - mySQL 연결 (0) | 2014.08.30 |
---|---|
Unix [Linux] Shell Script 의 기본 - if else (0) | 2014.08.24 |
Unix [Linux] 에디터 vim 기본 사용법 (157) | 2014.08.09 |
간단하게 Ubuntu 14.04 를 Xubuntu 14.04 로 만들기 (35) | 2014.08.06 |
Unix [Linux] 기본 명령어 모음 (31) | 2014.08.06 |