2023. 3. 21. 13:27ㆍAWS 기반 데이터분석 처리 고급 SW 클라우드 개발자 양성과정
본인의 홈에 .plan 파일을 만들어놓음(휴가 갔는지 확인하려고)
[root@centos /allnew/shells]# ./file.sh centos
I will go to travel this weekend.
[root@centos /allnew/shells]# cat >> ~centos/.plan
destination is anywhere...hmhm
^C
[root@centos /allnew/shells]# ./file.sh centos
I will go to travel this weekend.
destination is anywhere...hmhm
[root@centos /allnew/shells]# vi dir.sh
[root@centos /allnew/shells]# ./dir.sh /work/shells (work에 shells 디렉토리가 있는지)
/work/shells directory is not exit~!!. (없다)
[root@centos /allnew/shells]# ./dir.sh /allnew/shells (allnew에 shells 디렉토리가 있는지 확인)
/allnew/shells directory is exit~!!. (있다)
**ch를 안한 이유 = copy해와서
#!/bin/bash
if [ -f /home/$1/.plan ]; then
cat /home/$1/.plan
else
echo "User $1 is not make .plan file."
7 fi
****중요
int(a) {
}
return a
***중요
function(x) {
}
function(10)
****중요 (main 안에 sum을 호출하려면 int sum(int, int)를 먼저 선언해줘야함
int sum(int, int) { ### 선언부 시작 (header 파일로 만듬)
}
main( , ) ###선언부 끝
sum(a, b); ###함수의 호출부 (lib파일로 만듬)
}
int sum(int,int) { ###함수의 구현부 시작
a = x + y;
} return: a ; ###함수의 구현부 끝
kill 시그널
1 - HUP
2 - INT
3 - Quit
9 - Kill
15 - TEM
20 - TSTP
useradd -u 1001 -g users -c "User1" -d /home/user1 -s /bin/bash -m user1
Username:X:uid:gid:commentt:home:shell
-p -u -g -c -d -s
uid:x:gid:connect:home:shell
-u pw -g -c -d -s
vi useradd.sh 에서 실행했을때
1 #!/bin/bash
2
3 i=1
4 uid=$1 (첫번째 파라미터)
5 cnt=$2 (두번째 파라미터)
6
7 while [ $i -le $cnt ]; do (2000 - less equal
8 let uid+=1
9 useradd -u $uid -g users -d /home/user$i -s /bin/bash user$i
10 passwd -d user$i
11 let i+=1
12 done
13 echo Complete!!
순서를 잘 외우기!!
Command -옵션 Parmeter
파일 읽어내는 파일 생성
v
1 #!/bin/bash
2
3 count=1
4 cat test | while read line
5 do
6 echo "Line $count : $line"
7 count=$[ $count + 1 ]
8 done
9 echo "Finishing processing the file."
while에 조건문이 없는데 파일의 끝 (EOD를 인식해서 자동으로 끝남)
1 #!/bin/bash
2
3 count=1
4 cat test | while read line
5 do
6 echo "Line $count : $line"
7 let count+= 1
8 done
9 echo "Finishing processing the file."