# Reboot the computer system - Windows ```bash shutdown /r ``` # Windows directory overview - recursive ```bash tree /f . ``` # Whitespace 제거 ```bash # awk awk '{$1=$1}1' filename.txt > output.txt # sed (in place) sed -i 's/[[:space:]]\+$//' filename.txt - `-i`: 파일을 직접 수정 (백업 없이) - `s/.../.../`: 치환 - `[[:space:]]\+
: 줄 끝의 모든 공백 문자(스페이스, 탭 등) 제거 # 공백 없이 한 줄로 출력 tr -d '\n\r[:space:]' < hash.txt > hash_oneline.txt ``` # Row 추출 ```bash sed -n '2p;3p;7p' hosts.txt awk 'NR==2 || NR==3 || NR==7' hosts.txt cat file.txt | sed -n '2p;3p;7p' some_command | awk 'NR==2 || NR==3 || NR==7' # range sed -n '2,5p' hosts.txt ``` # Column 추출 ```bash # last column awk '{print $NF}' file.txt awk '{print $2}' file.txt awk '{print $2, $3, $7}' file.txt # 구분자가 공백이 아니라면 awk -F'\t' '{print $2, $3, $7}' file.txt awk -F',' '{print $2, $3, $7}' file.txt # 출력 구분자 조정 awk '{print $2 ";" $3 ";" $7}' file.txt ``` # phpinfo - `DOCUMENT_ROOT` - `DISABLE_FUNCTIONS` # grep tip ```bash grep -Horni <text> dir grep -Horni password dir 2>/dev/null ``` # print data horizontally ```bash # 줄 마다 구분지어져 있는 파일 가로로 콤마로 구분지어서 출력하기 paste -sd, <filename> nmap -sCV $IP -p $(ports -sd, <filename>) ``` # /etc/hosts ```bash # linux /etc/hosts # windows C:\Windows\System32\drivers\etc\hosts # /etc/hosts DNS cache troubleshoot in Firefox about:networking#dns ``` # Encoding error ```bash Unicode text, UTF-16, little-endian text, with CRLF line terminators ``` - grep은 기본적으로 `UTF-8` 인코딩만 처리 해결 방법 ```bash # 1. iconv로 변환과 동시에 grep 사용 iconv -f utf-16 -t utf-8 fileMonitorBackup.log | grep "검색할단어" # 2. utf-8로 새 파일 만들고 grep 사용 iconv -f utf-16 -t utf-8 fileMonitorBackup.log -o fileMonitorBackup_utf8.log grep "error" fileMonitorBackup_utf8.log # 3. strings 사용 # -el 옵션은 리틀 인디언 UTF-16로 문자열 추출 strings -el fileMonitorBackup.log | grep "error" ```