정보
-
업무명 : ccat 명령어 소개 : cat 명령어 + 구문 강조
-
작성자 : 이상호
-
작성일 : 2020-03-25
-
설 명 :
-
수정이력 :
내용
[개요]
-
안녕하세요? 기상 연구 및 웹 개발을 담당하고 있는 해솔입니다.
-
cat 명령어 결과를 less 명령어로 구문 강조하려면 pygments과 source-highlight를 사용 가능하나 설정하기 어렵습니다.
-
반면에 ccat 명령어를 사용하면 손쉽게 구문 강조를 할 수 있습니다.
-
따라서 이 포스팅에서는 ccat 명령어를 소개해 드리고자 합니다.
[특징]
-
cat 명령어 결과를 강조하기 이용하여 효율적인 명령어가 필요하며 이 명령어는 이러한 목적을 달성하기 위해 고안된 소프트웨어
[기능]
-
소개
-
설치
-
사용법
[활용 자료]
-
없음
[자료 처리 방안 및 활용 분석 기법]
-
없음
[사용법]
-
없음
[사용 OS]
-
Windows 10
[사용 언어]
-
Linux (CentOS v7.3)
-
VMware Workstation Pro v15.5
세부 내용
[소개]
-
ccat 명령어는 언어 목록은 자바 스크립트 (Java Script), 자바 (Java), 루비 (Ruby), 파이썬 (Python), 고 (GO), 씨 (C)를 지원한다.
-
또한 ccat 개발자에 따르면 리눅스 기본 명령어 cat과 ccat의 처리 시간은 거의 차이 없다고 한다 (테스트 결과 참조).
[root linux@/SYSTEM/LINUX/ccat]# wc -l Execution.log
663359 Execution.log
[root linux@/SYSTEM/LINUX/ccat]# time cat Execution.log > /dev/null
real 0m0.023s
user 0m0.000s
sys 0m0.023s
[root linux@/SYSTEM/LINUX/ccat]# time ccat Execution.log > /dev/null
real 0m0.028s
user 0m0.006s
sys 0m0.022s
[설치]
-
설치 파일 다운로드
-------------- On 64-Bit --------------
wget https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz
-------------- On 32-Bit --------------
# wget https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-386-1.1.0.tar.gz
[root linux@/SYSTEM/LINUX/ccat]# wget https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz
--2020-03-25 10:16:38-- https://github.com/jingweno/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz
Resolving github.com (github.com)... 15.164.81.167
Connecting to github.com (github.com)|15.164.81.167|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/35140287/65ef6940-97af-11e5-8790-56ee48875c9e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200325%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200325T101550Z&X-Amz-Expires=300&X-Amz-Signature=3c840175c9789a7c1db8b6f43193fd39b8c0f3840f5698986a9d8e72f91bddbb&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dlinux-amd64-1.1.0.tar.gz&response-content-type=application%2Foctet-stream [following]
--2020-03-25 10:16:38-- https://github-production-release-asset-2e65be.s3.amazonaws.com/35140287/65ef6940-97af-11e5-8790-56ee48875c9e?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20200325%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200325T101550Z&X-Amz-Expires=300&X-Amz-Signature=3c840175c9789a7c1db8b6f43193fd39b8c0f3840f5698986a9d8e72f91bddbb&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dlinux-amd64-1.1.0.tar.gz&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.217.43.156
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.217.43.156|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1241295 (1.2M) [application/octet-stream]
Saving to: ‘linux-amd64-1.1.0.tar.gz’
100%[=====================================================================================================================>] 1,241,295 387KB/s in 3.1s
2020-03-25 10:16:42 (387 KB/s) - ‘linux-amd64-1.1.0.tar.gz’ saved [1241295/1241295]
-
압축 풀기 및 ccat 실행 바이너리 이동
ls
tar xfz linux-amd64-1.1.0.tar.gz
ls linux-amd64-1.1.0
cp linux-amd64-1.1.0/ccat /usr/local/bin/
ls -al /usr/local/bin/
[사용법]
-
도움말
[root linux@/SYSTEM/LINUX/ccat]# ccat --help
FILE 또는 표준 입력을 표준 출력으로 채색합니다.
용법:
ccat [OPTION] ... [FILE] ...
플래그 :
--bg = "light": 터미널의 배경에 따라 "light"또는 "dark"로 설정
-C, --color = "auto": 출력을 채색합니다. 값은 "never", "always"또는 "auto"일 수 있습니다.
-G, --color-code = : 색상 코드 설정
-h, --help = false : ccat에 대한 도움말
--html = false : 출력 HTML
--palette = false : 색상 표 표시
-v, --version = false : 버전 표시
기본적으로 색상을 사용하는 것은 --color = auto입니다. --color = auto를 사용하면
ccat은 표준 출력이 터미널에 연결된 경우에만 색상 코드를 방출합니다.
색상 코드는 -G KEY = VALUE로 변경할 수 있습니다. 색상 코드 목록
--palette로 찾을 수 있습니다.
-
기본값으로 출력
head Execution.log | ccat
-
--palatte 옵션을 통해 색상 확인
ccat --palette
-
--bg=dark 옵션을 통해 배경색 다크 모드 (dark)로 변경
head Execution.log | ccat --bg=dark
-
-G String="_darkblue_" -G Plaintext="darkred" 옵션을 통해 색상 지정
head Execution.log | ccat -G String="_darkblue_" -G Plaintext="darkred"
-
--html 옵션을 통해 HTML 형식으로 출력
head Execution.log | ccat --html
[root linux@/SYSTEM/LINUX/ccat]# head Execution.log | ccat --html
<style>
.black { color: black; }
.blink { color: blink; }
.blue { color: blue; }
.bold { color: bold; }
.brown { color: brown; }
.darkblue { color: darkblue; }
.darkgray { color: darkgray; }
.darkgreen { color: darkgreen; }
.darkred { color: darkred; }
.darkteal { color: darkteal; }
.darkyellow { color: darkyellow; }
.faint { color: faint; }
.fuchsia { color: fuchsia; }
.fuscia { color: fuscia; }
.green { color: green; }
.lightgray { color: lightgray; }
.overline { color: overline; }
.purple { color: purple; }
.red { color: red; }
.reset { color: reset; }
.standout { color: standout; }
.teal { color: teal; }
.turquoise { color: turquoise; }
.underline { color: underline; }
.white { color: white; }
.yellow { color: yellow; }
</style>
<pre>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">44</span> <span class="darkred">:</span> <span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span> <span class="darkred">[</span><span class="teal">START</span><span class="darkred">]</span> <span class="teal">Realtime_Schedule_Web_Image_Crawling</span><span class="darkred">.</span><span class="darkblue">csh</span> <span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span><span class="darkred">=</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">44</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110002.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110002.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">44</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110004.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110004.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">45</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110006.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110006.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">45</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110008.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110008.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">46</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110010.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110010.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">47</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110012.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110012.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">47</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110014.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110014.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">47</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110016.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110016.srv.png S</span>
<span class="darkblue">2020</span><span class="darkred">/</span><span class="darkblue">01</span><span class="darkred">/</span><span class="darkblue">11</span> <span class="darkblue">00</span><span class="darkred">:</span><span class="darkblue">02</span><span class="darkred">:</span><span class="darkblue">47</span> <span class="darkblue">https</span><span class="darkred">:</span>//nmsc.kma.go.kr/IMG/GK2A/AMI/PRIMARY/L1B/COMPLETE/FD/201912/11/00/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110018.srv.png /root/TEST/TMP/gk2a_ami_le1b_rgb-daynight_fd020ge_201912110018.srv.png S</span>
</pre>
참고 문헌
[논문]
- 없음
[보고서]
- 없음
[URL]
- CentOS 6
문의사항
[기상학/프로그래밍 언어]
- sangho.lee.1990@gmail.com
[해양학/천문학/빅데이터]
- saimang0804@gmail.com
본 블로그는 파트너스 활동을 통해 일정액의 수수료를 제공받을 수 있음
'프로그래밍 언어 > Linux' 카테고리의 다른 글
[Linux] Awk를 이용하여 텍스트/숫자 빅데이터 자료 처리 및 통계 계산 (0) | 2020.07.15 |
---|---|
[Linux] ccze 명령어 소개 : 로그 (log) 기록에 컬러 출력 (0) | 2020.03.25 |
[Linux] 리눅스 사용자를 위한 cat 명령어의 사용법 (주요 사용 용도 : 파일 내용 확인, 파일 합치기) (0) | 2020.03.14 |
[Linux] 리눅스 사용자를 위한 awk 명령어의 사용법 (주요 사용 용도 : 텍스트 데이터 처리) (1) | 2020.03.14 |
[Linux] 리눅스 VMware Workstation에서 "Failed to start the virtual machine" 오류 해결 방법 (0) | 2020.02.17 |
최근댓글