Shell 3

C

[ Linux / bash / zsh ] 텍스트의 앞 뒤 줄을 생략하고 중간만 출력하기

head & tail 명령어 # head 1 ~ 10줄만 출력 # tail 맨 마지막 줄에서 거꾸로 10줄만 출력 abc.txt 파일에 줄마다 각각 1 ~ 20이 입력되어 있을 때, cat abc.txt 위 명령어의 출력 결과는 다음과 같다. 1 2 3 4 5 . . . 16 17 18 19 20 head와 tail은 "-n" 플래그로 출력할 줄 수를 지정해줄 수 있다. 음수, 양수를 입력 해 생략할 줄을 반전시킬 수 있다. cat abc.txt | head -n 5 # 1 ~ 5 cat abc.txt | head -n -5 # 1 ~ 15 cat abc.txt | tail -n 5 # 5 ~ 20 cat abc.txt | tail -n -5 # 5 ~ 20 cat abc.txt | tail -n +5 ..

Dev/Linux 2021.12.19

C

[Makefile] make (e=2): recipe for target 'clean' failed

# 에러전문 PS D:\dev\Repositiory\Sandbox\C\Makefile_test> mingw32-make clean rm -f *.o\ process_begin: CreateProcess(NULL, rm -f *.o, ...) failed. make (e=2): . Makefile:21: recipe for target 'clean' failed mingw32-make: *** [clean] Error 2 # 해결방법 현재 사용하는 쉘이 뭔지 확인해보자... Powershell -> Windows Bash -> Linux Powershell에서는 rm 명령어를 "-rf"와 같은 플래그와 함께 사용할 수 없다.

C

[Linux] Shell Script

Shell Script IO Redirection > : 출력되는 방향을 다른 곳으로 돌림 Standard Output Redirection 커맨드 실행 후 출력되는 결과(Output)를 파일로 저장 ls -l > result.txt // 파일목록을 result.txt에 저장 Angle bracket('>')은 Standard Output만 Redirect하므로 아래와 같이 출력되는 Error는 파일로 만들 수 없다 // result.html는 존재하지 않는 파일 rm result.html > result.txt // 에러가 출력되지만 result.txt에 저장되지는 않는다. >에는 앞에 1이 생략되어 있는데, 이건 Standard Output을 의미한다. Angle bracket 앞에 2..

Dev/Linux 2021.08.14