프로그래밍/리눅스
실무에서 꼭 필요한 리눅스 명령어
자바조아!
2024. 2. 8. 05:34
파일 생성
# 파일 생성
# 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
파일 수정
특정 단어 찾아서 바꾸기
# sed -i 's/찾을문자열/바꿀문자열/g' <파일이름>
sed -i 's/old/new/g' example.txt
sed -i 's/old/new/g' *.txt
파일 검색
# 로그에서 에러를 찾음.
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