강좌
클라우드/리눅스에 관한 강좌입니다.
리눅스 분류

선배들의 노하우 빼내기 제2탄 : 파일명 지정

작성자 정보

  • 관리자 작성
  • 작성일

컨텐츠 정보

본문

선배들의 노하우 빼내기 제2 : 파일명 지정

 

 

 

 

 

만약 script를 실행하면서 특정파일명을 지정하면 그 파일에 작업내용이 저장될 것이다.

 

 

 

 

 

 , 앞의 예에서는 script를 실행하면서 특정한 파일을 지정하지 않았기 때문에 기본파일인 typescript파일에 터미널의 작업내용이 저장되었다.

 

 

 

 

 

 이번에는 script를 실행하면서 터미널의 모든 내용이 저장될 파일을 직접 지정하여 지정된 파일에 저장되는 예를 보겠다.

 

 

 

 

 

다음 예는 script를 입력하면서 sulinux.txt라는 파일이름을 지정하였다.

 

 

 

 , “script sulinux.txt”라는 명령어로 인하여 이후부터 exit를 입력할 때까지 모든 작업내용이  sulinux.txt파일에 저장될 것이다.

 

 

 

 

 

 

 

[root@sulinux ~]#script sulinux.txt

Script started, file is sulinux.txt

[root@sulinux ~]#

[root@sulinux ~]#ping www.yahoo.co.kr

PING yahoo.co.kr (203.212.171.217) 56(84) bytes of data.

64 bytes from rc.vip.kr1.yahoo.com (203.212.171.217): icmp_seq=1 ttl=52 time=8.67 ms

64 bytes from rc.vip.kr1.yahoo.com (203.212.171.217): icmp_seq=2 ttl=52 time=5.88 ms

 

--- yahoo.co.kr ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1000ms

rtt min/avg/max/mdev = 5.881/7.276/8.671/1.395 ms

[root@sulinux ~]#

[root@sulinux ~]#

[root@sulinux ~]#route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

192.168.0.0     *               255.255.255.0   U     0      0        0 eth1

169.254.0.0     *               255.255.0.0     U     0      0        0 eth1

default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0

[root@sulinux ~]#

[root@sulinux ~]#exit

Script done, file is sulinux.txt

[root@sulinux ~]#

 

 

 

 

여기서 주의할 것은 이미 sulinux.txt파일이 존재하고 있다면 기존의 내용이 지워지고 새로운 내용으로 저장이 되므로 주의해야 한다.

 

 

 

 

 

 

 

 

그리고 다음은 sulinux.txt에 저장된 내용을 확인 한 것이다.

 

 

 

 

 

 “ls -l sulinux.txt”로 확인해 보면 sulinux.txt라는 파일이 있으며 이 파일은 script명령어의 결과 생성된 파일이며 이 파일에는 script명령어를 실행한 이후의 모든 작업내용이 저장되어 있다.

 

 

 

 

 

 

 

[root@sulinux ~]#ls -l sulinux.txt

-rw-r--r-- 1 root root 1115  3  9 03:03 sulinux.txt

[root@sulinux ~]#

[root@sulinux ~]#cat sulinux.txt

Script started on 2009년 03월 09일 (월)오전 03 03 30

[root@sulinux ~]#

[root@sulinux ~]#ping www.yahoo.co.kr

PING yahoo.co.kr (203.212.171.217) 56(84) bytes of data.

64 bytes from rc.vip.kr1.yahoo.com (203.212.171.217): icmp_seq=1 ttl=52 time=8.67 ms

64 bytes from rc.vip.kr1.yahoo.com (203.212.171.217): icmp_seq=2 ttl=52 time=5.88 ms

 

--- yahoo.co.kr ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1000ms

rtt min/avg/max/mdev = 5.881/7.276/8.671/1.395 ms

[root@sulinux ~]#

[root@sulinux ~]#

[root@sulinux ~]#route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

192.168.0.0     *               255.255.255.0   U     0      0        0 eth1

169.254.0.0     *               255.255.0.0     U     0      0        0 eth1

default         192.168.0.1     0.0.0.0         UG    0      0        0 eth0

[root@sulinux ~]#

[root@sulinux ~]#exit

 

Script done on 2009년 03월 09일 (월)오전 03 03 41

[root@sulinux ~]#

 

 

 

 

sulinux.txt파일에 저장된 내용을 확인하기 위하여 “cat sulinux.txt”명령어를 실행하였다.

 

 

 

  그 결과 script를 실행하고 exit로 종료할 때까지의 모든 작업내용이 그대로 저장되어 있다는 것을 확인할 수 있다.

 

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,138 명
  • 현재 강좌수 :  36,196 개
  • 현재 접속자 :  808 명