Troubleshoot

pip3 troubleshoot

파일/폴더 나열

<aside>

# Windows
tree /f

# Linux
ls -R
ls -aR

</aside>

압축 파일

<aside>

binwalk [filename]

Since spreadsheet files such as .xlsx and .xlsm are just compressed files, we can read the Macros in the format of XML files by extracting them from the excel files.

binwalk -e [filename]

</aside>

컴퓨터 시스템 재부팅 - 윈도우

shutdown /r
shutdown /r /t 0

Whitespace 제거

<aside>

# 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

</aside>

Row / Column 추출

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
# 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