본문 바로가기

Linux14

Shebang (#!) Shebang 이란? Sharp(#)' + 'Bang(!)의 합성어 #!은 2Byte의 매직넘버(magic number)로 Unix계열 OS(리눅스, Mac)에서 스크립트(bash, python등등) 코드 최상단에서 해당 파일을 해석해 줄 인터프리터의 절대경로를 지정 스크립트를 실행할 때 (예 : ./script명령 줄에서) Linux는 스크립트를 실행하는 데 사용되는 프로그램을 파악하기 위해 shebang 줄이라는 특수 줄을 사용합니다. 예) #!/bin/bash ⇒ Bash 스크립트 #!/usr/bin/env python3 ⇒ Python 스크립트용. shebang 줄이 없으면 기본적으로 Bash에서 스크립트를 실행. (즉, 쉘 스크립트로) 셸 스크립트가 아니라 파이썬 스크립트일 경우 #!/bin/b.. 2021. 2. 25.
[macOS] sed -i 에러 sed: 1: "/etc/hosts": extra characters at the end of d command 발생 macOS에서 sed -i를 사용하여 파일안에 있는 문자를 치환하려 하는 경우, 아래와 같이 하면 작동하지 않는다. sed 's/foo/bar/g' file 해결 방법 # BSD/macOS sed sed -i '' 's/foo/bar/' # GNU sed (대부분의 Linux) sed -i 's/foo/bar/g' BSD/macOS sed가 정상적으로 작동하지 않는 케이스들 **sed -i 's/foo/bar/' file # Breaks; script is misinterpreted as backup-file suffix sed -i'' 's/foo/bar/' file # Ditto se.. 2021. 2. 24.
man signal (mac os, 파파고 번역) NAME sigal - 단순화된 소프트웨어 신호 설비 LIBRARY 표준 C 라이브러리 (libc, -lc) SYNOPSIS #include void (*signal(int sig, void (*func)(int)))(int); or in the equivalent but easier to read typedef'd version: typedef void (*sig_t) (int); sig_t signal(int sig, sig_t func); DESCRIPTION 이 signal() 설비는 보다 일반적인 sigaction(2) 설비에 대한 단순화된 인터페이스이다. 신호는 도메인 외부에서 온 프로세스를 조작할 수 있을 뿐만 아니라 프로세스가 자체 또는 자신(자녀)의 복사본을 조작할 수 있도록 합니다. 두.. 2021. 2. 6.
tmux - alias, sh를 이용하여 편리하게 사용하기 alias 등록하기 (https://sondho.tistory.com/44) # tmux alias t='tmux' alias tn='~/git/my-settings/my-sh/tmux/tmux_new_name.sh' alias ta='tmux a #' alias tan='~/git/my-settings/my-sh/tmux/tmux_a_t_name.sh' alias tl='tmux ls' alias tk='~/git/my-settings/my-sh/tmux/tmux_kill-session.sh' tmux a # 세션을 재연결하는 명령어 a는 attach를 뜻함 #는 특정 세션번호를 뜻하는 와일드카드. 사용자가 명시적으로 세션번호를 입력하지 않아도 가장 최근에 사용한 세션을 자동으로 찾아서 연결합니다. t.. 2021. 1. 22.