linux

BackEnd_Ash.log·2020년 5월 25일
0

cp

  • 복사하는 명령어
  • 디렉토리를 복사할때는 -r 옵션을 주어야합니다.
$ ls
testdir/  testfile


$ cp testfile1 testfile_cp
$ ls
testdir/  testfile  testfile_cp

# 폴더 복사
$ cp -r testdir testdir_cp
$ ls
testdir/  testdir_cp/  testfile  testfile_cp

cat ( concatenate )

  • 파일의 내용을 출력할 수 있음
  • 파일 여러개를 합쳐서 하나의 파일로 만들 수 있음
출력 : cat 파일명
파일 합치기 : cat 파일명1 파일명2 > 파일명3
파일 내용 덧붙이기 : cat 파일명1 >> 파일명2 

$ ls
file1  file2  file3


$ cat file1
1


$ cat file2
2


$ cat file3
3

$ cat file1 file2 > file1_2
$ ls
file1  file1_2  file2  file3


$ cat file1_2
1
2


$ cat file1 >> file2
$ cat file2
2
1


$ cat > file4
hello
world
(작성이 끝나면 ctrl +d 로 파일 저장)


$ cat file4
hello
world

head

  • 앞부분을 출력 해줌
  • head /etc/passwd ( 앞 부분 부터 10줄 출력 )
  • cat /etc/passwd | head

-n

출력해주는 숫자를 지정할수 있습니다.

  • cat /etc/passwd | head -n 2
$ cat testfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

$ head -3 testfile
1
2
3

tail

  • 문서 내용의 뒷부분 출력
  • default 로 10줄을 출력한다.
  • tail /etc/passwd -n 1
  • tail /etc/passwd -n +5
  • cat /etc/passwd | tail -n 15
  • cat /etc/passwd | tail -n +5
$ head -3 testfile
1
2
3

tree 명령어

brew install tree
# depth 만 표시 
tree -L 2 -N

# depth 와 directory 만 표시
tree -L 2 -d -N

# depth , directory only , no indentation + full path
tree -L 2 -d -fi -N

# depth , 특정 폴더 제외
tree -N -L 2 -d -I "node_modules | tests"
profile
꾸준함이란 ... ?

0개의 댓글