파일 행 수 세기

파일의 행의 수를 셀 때 다음과 같은 명령어를 사용하면 된다

$cat README.md | wc -l

wc

word count 의 약자

  • 행 수, 단어 수, 바이트 수 등을 세는 리눅스 명령어

  • wc 옵션 값

    $ wc --help
    Usage: wc [OPTION]... [FILE]...
    or: wc [OPTION]... --files0-from=F
    Print newline, word, and byte counts for each FILE, and a total line if
    more than one FILE is specified. With no FILE, or when FILE is -,
    read standard input. A word is a non-zero-length sequence of characters
    delimited by white space.
    The options below may be used to select which counts are printed, always in
    the following order: newline, word, character, byte, maximum line length.

    -c, --bytes            print the byte counts
    -m, --chars            print the character counts
    -l, --lines            print the newline counts
        --files0-from=F    read input from the files specified by
                             NUL-terminated names in file F;
                             If F is - then read names from standard input
    -L, --max-line-length  print the length of the longest line
    -w, --words            print the word counts
        --help     이 도움말을 표시하고 끝냅니다
        --version  버전 정보를 출력하고 끝냅니다
  • 가장 많이 사용하는 것은 파일의 행의 수를 알아볼때 사용 한다.

    $ cat README.md | wc -l
    86430125
    $ wc -l ./README.md
    86430125 ./README.md

참고: https://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_wc

Postgresql Install & remove

기존 Postgresql 삭제하기

$ sudo systemctl stop postgresql-9.6.service

서비스 상태 보기

$ sudo systemctl list-unit-files postgresql*
UNIT FILE              STATE
postgresql-9.6.service enabled

서비스 비활성화

$sudo systemctl disable postgresql-9.6.service

postgresql 홈디렉토리 삭제

root# rm -rf /var/lib/pgsql

postgresql 계정 삭제

root$ userdel postgres
root$ groupdel postgres

패키지 로 설치 했기 때문에 패키지 삭제

설치된 패키지의 리스트를 확인하기 위해 아래 명령어

#yum list installed *postgres*

postgresql 패키지 삭제

#yum remove *postgres*

postgres패키지가 잘 삭제 됬는지 확인

#yum list installed *postgres*

Postgresql 10 설치하기

yum repostory 등록 ?

$ sudo rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm



$sudo yum install postgresql10

설치 중 아래와 같이 오류가 나는점 ??

# rpm -Uvh https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm(을)를 복구합니다
준비 중...                         ################################# [100%]
        pgdg-redhat-repo-42.0-4.noarch 패키지는 이미 설치되어 있습니다

이미 yumrepo 에 설치 되어있다고 해서 postgresql을 설치 해봤다. 그러니....에러가..

$ sudo yum install -y postgresql10
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * extras: mirror.kakao.com
 * updates: ftp.jaist.ac.jp
No package postgresql10 available.
Error: Nothing to do

아래와 같은 명령어로 리스트를 확인해보니 96 버전은 있는데 10버전이 없었다.

#yum list installed *postgres*

yum repolist를 삭제하고 다시 해볼까 ??

$ll /etc/yum.repos.d/

pgdg 패키지를 yum repos.d 에서 삭제

$sudo rm -f /etc/yum.repos.d/pgdg-redhat-all.repo

이후 다시 확인 하면 pgdg repo가 삭제된것을 알수 있다.

[root@spark03 yum.repos.d]# ll
합계 124
-rw-r--r--. 1 root root  1664 11월 23  2018 CentOS-Base.repo
-rw-r--r--. 1 root root  1309 11월 23  2018 CentOS-CR.repo
-rw-r--r--. 1 root root   649 11월 23  2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root   630 11월 23  2018 CentOS-Media.repo
-rw-r--r--. 1 root root  1331 11월 23  2018 CentOS-Sources.repo
-rw-r--r--. 1 root root  5701 11월 23  2018 CentOS-Vault.repo
-rw-r--r--. 1 root root   314 11월 23  2018 CentOS-fasttrack.repo
drwxr-xr-x. 4 root root  4096  5월 31 17:10 dbserver8530
-rw-r--r--. 1 root root   607  5월 14 11:43 setup.json

이후 다시 pgdg...를 repo에 등록해준다

$ sudo rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm



$sudo yum install postgresql10 postgresql10-server

그럼 설치 완료

다음리눅스는 yum과 rpm 에 대해서 공부 해보자

참고

https://tecadmin.net/install-postgresql-server-centos/

https://zetawiki.com/wiki/Yum_repo_%EC%A0%9C%EA%B1%B0

'BackEnd > Linux' 카테고리의 다른 글

Bash 프로그래밍 기초 - 파라미터 받아오기  (0) 2019.08.20
Bash 프로그래밍 기초 - If  (0) 2019.08.20
Bash 프로그래밍 기초 - for  (0) 2019.08.20
Bash 프로그래밍 기초 - array  (0) 2019.08.19
파일 행 수 세기  (1) 2019.07.09

+ Recent posts