[Born2beroot] Command

Cadet_42·2021년 7월 4일
0

Born2beroot

목록 보기
2/5

Born2beroot monitoring.sh 개념들

1. grep (Global Regular Expression Print)

grep 명령어는 파일 혹은 일반적인 입력값을 검토하여 특정 패턴(문자열)이 존재하는지 확인하며,확인된 줄을 출력하여 사용자가 알 수 있도록 처리해주는 역할을 함
텍스트 파일에서 원하는 문자열이 들어간 행을 찾아 출력하는 명령어.

grep 사용방법
grep [옵션][패턴][검토할파일명]

grep searches input files for matches to the patterns.
When it finds a match in a line, it copies the line to standard output(by default), or produces whatever other sort of output you have requested with option.

2. WC (Word Count)

Easy way to count the lines, words and characters in a file or in output from some other command.

wc : prints the number of line, word and character by order.

wc -l : prints the number of lines present in a file
wc -w : prints the number of words present in a file
wc -c : prints and displays count of bytes present in a file
wc -m : displays count of characters from a file

3. AWK

Scripting language used for manipulating data & generating reports.

awk는 파일로부터 레코드(record)를 선택하고 선택된 레코드에 포함된 값을 조작하거나 데이터화하는것을 목적으로 사용하는 프로그램이다. 즉, awk 명령의 입력으로 지정된 파일로부터 데이터를 분류한 다음, 분류된 텍스트 데이터를 바탕으로 패턴 매칭 여부를 검사하거나 데이터 조작 및 연산 등의 액션을 수행하고, 그 결과를 출력하는 기능을 수행함.

free -m : show free memory
| grep Mem : show Mem part inside of the free memory

$3 : 73 (Mem_used)
$2 : 987 (Mem_total)

(%.2f%%) : % is symbol for variable
.2f%% : how many digit decimal points you want to printf %f string formatting option treats the value as a decimal %.2f : 소수점 두자리 수까지 나타냄 (only 2 digits will appear after the decimal)
%.4f : 소수점 네자리수까지 나타냄 (only 4 digits will appear after the decimal)

출처:

  1. grep 개념
    https://wiseworld.tistory.com/97
  2. awk 개념
    https://recipes4dev.tistory.com/171
    https://www.geeksforgeeks.org/awk-command-unixlinux-examples/
    https://www.baeldung.com/linux/grep-sed-awk-differences
    https://www.codecademy.com/forum_questions/51382b87954cc276830008f9
profile
안녕하세요! 개발공부를 하고 있습니다. 감사히 배우겠습니다. ;)

0개의 댓글