메뉴 닫기

bat 명령어: cat을 뛰어넘는 파일 출력 도구

batcat 명령어의 향상된 버전으로, 파일 내용을 출력할 때 다음과 같은 추가 기능을 제공합니다.

  • 문법 강조 (Syntax Highlighting): 코드 파일을 보다 가독성 높게 출력

  • 라인 번호 표시: 파일 내용을 줄 번호와 함께 출력

  • 파일 페이징 기능: less와 결합하여 긴 파일을 스크롤하며 확인 가능

  • Git 연동: 변경된 부분을 강조하여 출력

bat은 cat과 사용법이 거의 동일하면서도 훨씬 강력한 기능을 제공합니다.

 

bat 설치 방법 (Ubuntu 22.04)

# apt install bat

# batcat –version

 

bat 명령어 사용예제

# batcat [파일명]

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Apache HTTP Server Test Page</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 50px;
background-color: #f8f9fa;
}
h1 {
color: #007bff;
}
p {
color: #555;
}
.container {
max-width: 600px;
margin: auto;
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to Apache!</h1>
<p>If you see this page, the Apache web server is working correctly.</p>
<p>Edit <code>/var/www/html/index.html</code> to change this page.</p>
</div>
</body>
</html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Apache HTTP Server Test Page</title> <style> body { font-family: Arial, sans-serif; text-align: center; margin: 50px; background-color: #f8f9fa; } h1 { color: #007bff; } p { color: #555; } .container { max-width: 600px; margin: auto; background: white; padding: 20px; border-radius: 10px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1); } </style> </head> <body> <div class="container"> <h1>Welcome to Apache!</h1> <p>If you see this page, the Apache web server is working correctly.</p> <p>Edit <code>/var/www/html/index.html</code> to change this page.</p> </div> </body> </html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Apache HTTP Server Test Page</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            margin: 50px;
            background-color: #f8f9fa;
        }
        h1 {
            color: #007bff;
        }
        p {
            color: #555;
        }
        .container {
            max-width: 600px;
            margin: auto;
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Welcome to Apache!</h1>
        <p>If you see this page, the Apache web server is working correctly.</p>
        <p>Edit <code>/var/www/html/index.html</code> to change this page.</p>
    </div>
</body>
</html>

 

# batcat [파일명1 ] [파일명2]

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
def hello():
print("Hello, Bat1.py test!")
hello()
def hello(): print("Hello, Bat1.py test!") hello()
def hello():
    print("Hello, Bat1.py test!")
hello()
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
def hello():
print("Hello, Bat2.py test!")
hello()
def hello(): print("Hello, Bat2.py test!") hello()
def hello():
    print("Hello, Bat2.py test!")
hello()

 

bat vs cat 비교

기능 cat bat
기본적인 파일 출력 ✅ ✅
문법 강조 ❌ ✅
줄 번호 표시 ❌ ✅
긴 파일 페이징 ❌ ✅ (less 자동 연동)
Git 변경 사항 강조 ❌ ✅

 

 

Subscribe
Notify of
guest


0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x