우아한 프로그래밍

1. 파일 생성

<code />
# 파일 생성 # cat > <<파일명>> 하면 붙여넣기가 가능한데 그만 입력하고 싶으면 Ctrl + D cat > nginx-pod.yaml apiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx-container image: nginx ports: - containerPort: 80

2. 파일 수정

2.1. 특정 단어 찾아서 바꾸기

<code />
# sed -i 's/찾을문자열/바꿀문자열/g' <파일이름> sed -i 's/old/new/g' example.txt sed -i 's/old/new/g' *.txt

3. 파일 검색

<code />
# 로그에서 에러를 찾음. grep -n ERROR pod-nginx-label.yaml # 너무 많은 경우 뒤에서 개수만큼 자름 grep -n ERROR pod-nginx-label.yaml | tail -100 # 어느 라인에 에러가 있는지 특정했으면 그 라인의 아래로 줄수만큼 표시 # tail -n +<에러가발생한 라인번호> pod-nginx-label.yaml | head -n <에러라인부터 몇라인 출력> tail -n +30 pod-nginx-label.yaml | head -n 100
profile

우아한 프로그래밍

@자바조아!

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!