티스토리 뷰
shell programming
$ cat a.c
main(){
for(;;);
} //needs compile, not a shell script
$ cat myprog
# this is the program myprog
date
ls -F
//shell script
shell script and child process
$ color=blue
$ cat color1
echo You are now running program: color1
echo the value of the variable color is: $color
$ color1
You are now running program: color1
the value of the variable color is:
$ cat color4
echo There are $# command line arguments, 인수의 수
echo They are $*
echo The first command line argument is $1
$ color4 red white blue black
There are 4 command line arguments
They are red white blue black
The first command line argument is red
read command
{
$ cat color6
echo This program prompts for user input
echo "Please enter your favorite two colors -> \c" // 자동 newline 방지 "\c"
read color_a color_b
echo The colors you entered are: $color_b $color_a
Additional Techiques
#!/usr/bin/"shell_name" define shell script
Debugging mode
$ sh -x color5 A B C D E F G
+ orig_args=A B C D E F G //code를read한 부분
+ echo There are 7 command line arguments
There are 7 command line arguments //terminal에서 표시되는 부분
+ echo They are A B C D E F G
They are A B C D E F G
+ echo Shifting two arguments
Shifting two arguments
+ shift 2
+ echo There are 5 command line arguments
There are 5 command line arguments
+ echo They are C D E F G
They are C D E F G
+ echo Shifting two arguments
Shifting two arguments
+ shift 2
+ final_args=E F G
+ echo Original arguments are: A B C D E F G
Original arguments are: A B C D E F G
+ echo Final arguments are: E F G
Final arguments are: E F G
Exercise
echo welcome $(whoami)
date
who
echo "\n\n"
who am i | tr -s " " | cut -f1,2 -d" "
echo bye bye
========
grep user /etc/passwd |pr -t -6
echo enter your name:
read usr_name
grep $usr_name /etc/passwd | cut -f6 -d:| ls
'IoT 과정' 카테고리의 다른 글
HPUX - Shell Programming - Loops (0) | 2017.06.23 |
---|---|
HPUX - Shell Programming - Branches (0) | 2017.06.23 |
HPUX - Process Control (0) | 2017.06.22 |
HPUX - Pipes (0) | 2017.06.22 |
HPUX - Input and Output Redirection (0) | 2017.06.22 |
- Total
- Today
- Yesterday
- 자바스크립트
- 아레나
- 최단경로 알고리즘
- 대규모 시스템 설계 기초
- 항해99
- 엄청난 인내심과 시뮬레이션을 위한 아레나 툴
- paul wilton
- 로젠
- 아레나 시뮬레이션
- Propositional and Predicate Logic
- 백준
- 이산수학
- Arena
- 이산 수학
- javascript
- Grafana
- Simulation
- arena simulation
- 그라파나
- flutter
- Discrete Mathematics
- 명제논리
- rosen
- 아레나시뮬레이션
- 데이터 중심 애플리케이션 설계
- 시뮬레이션
- beginning javascript
- 가상 면접 사례로 배우는 대규모 시스템 설계 기초
- 자바스크립트 예제
- grafana cloud
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |