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
'프로그래밍 > 리눅스' 카테고리의 다른 글
리눅스에서 VIM 특정 단어에 컬러를 부여하는 방법 (0) | 2024.12.24 |
---|---|
리눅스(Ubuntu) 에서 Shell Script 서비스를 생성하는 방법 (0) | 2024.12.17 |
버추얼박스(VirtualBox)에 Nat Network 설정하는 방법에 대해 알아보자 (1) | 2024.02.03 |
버추얼박스(VitualBox)에 우분투(Ubunto) 설치 하는 방법에 대해 알아보자 (0) | 2024.02.03 |
리눅스(Linux) 파일에서 단어 검색하기 (0) | 2023.02.06 |