Ccat – 使用語法突出顯示輸出內(nèi)容
ccat是與Linux中的cat命令類似的命令行工具,該命令顯示文件的內(nèi)容并突出顯示Javascript,Java,Go,Ruby,C,Python和Json的編程語言語法。
要在Linux中安裝ccat工具,需要確保wget工具已安裝。以下是安裝wget命令:
- # 下面是再Centos/RHEL/Fedora中安裝命令。
- yum -y install wget
- # 下面是再Ubuntu/Deepin/Debian中安裝命令。
- apt -y install wget
下面從github中下載ccat的壓縮包:
- [root@localhost ~]# wget https://github.com/owenthereal/ccat/releases/download/v1.1.0/linux-amd64-1.1.0.tar.gz
解壓縮,并蔣二進制文件復(fù)制到/usr/local/bin目錄中:
- [root@localhost ~]# tar xvf linux-amd64-1.1.0.tar.gz
- [root@localhost ~]# cd linux-amd64-1.1.0/
- [root@localhost linux-amd64-1.1.0]# cp -p ccat /usr/local/bin/
為了針對系統(tǒng)配置文件測試ccat的功能,下面查看幾個linux中的配置文件。
- [root@localhost ~]# ccat /etc/sysconfig/network-scripts/ifcfg-ens160
- [root@localhost ~]# ccat /etc/fstab
下面是如何讓ccat替換掉cat工具,再/etc/bashrc文件中添加一個cat的別名:
- # Centos/RHEL/Fedora
- [root@localhost ~]# echo "alias cat='/usr/local/bin/ccat'" >> /etc/bashrc
- [root@localhost ~]# source /etc/bashrc
- # Ubuntu/Deepin/Debian
- $ sudo echo "alias cat='/usr/local/bin/ccat'" >> /etc/profile
- $ sudo source /etc/profile
ccat工具還可用于顯示多個文件并以HTML格式輸出,如以下示例所示:
- [root@localhost ~]# ccat --html /etc/sysconfig/network-scripts/ifcfg-ens160 /etc/sysconfig/iptables /etc/fstab > /var/www/html/ccat.html
需要安裝apache或nginx等web服務(wù)器,才能在網(wǎng)頁查看?;蛘邔?html文件在圖形化界面打開也可以。
本文轉(zhuǎn)載自微信公眾號「Linux就該這么學」,可以通過以下二維碼關(guān)注。轉(zhuǎn)載本文請聯(lián)系Linux就該這么學公眾號。