linuxfromscratch

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
linuxfromscratch [2025/12/18 13:37] – [토막 상식] baecylinuxfromscratch [2025/12/21 18:46] (현재) – [PS1 설정] baecy
줄 2: 줄 2:
  
 ==== 설치된 Perl Module 목록 확인 ==== ==== 설치된 Perl Module 목록 확인 ====
 +=== Perl과 기본 시스템 도구만 이용 ===
 <codeprism bash> <codeprism bash>
 #!/bin/sh #!/bin/sh
줄 10: 줄 10:
 # List of installed Perl Modules # List of installed Perl Modules
  
 +# grep "$pattern" - $1이 비어있으면 전체 검색(.), 있으면 $1로 검색
 # /"Module"/ - "Module" 가 포함된 줄만 선택 # /"Module"/ - "Module" 가 포함된 줄만 선택
 # !seen[$NF]++ - awk 내부 배열을 사용해서 중복 제거 # !seen[$NF]++ - awk 내부 배열을 사용해서 중복 제거
줄 15: 줄 16:
 # sort --ignore-case (-f) | 대소문자 구분없이 정렬 # sort --ignore-case (-f) | 대소문자 구분없이 정렬
  
-perldoc perllocal | awk '/"Module"/ {if (!seen[$NF]++) print $NF}' | sort --ignore-case+pattern="${1:-.}" 
 + 
 +perldoc perllocal | awk '/"Module"/ {if (!seen[$NF]++) print $NF}' | sort --ignore-case | grep --color=always -E -i "$pattern"
  
 # End ~/bin/pml.sh # End ~/bin/pml.sh
 </codeprism> </codeprism>
 +<codeprism cmd=true cmdout=2-10>
 +pml.sh "tiny|test"
 +Capture::Tiny
 +Class::Tiny
 +Test::Deep
 +Test::Exception
 +Test::Fatal
 +Test::Needs
 +Test::Warnings
 +Try::Tiny</codeprism>
 +
 +이런 방식으로 다중 검색도 가능함.
 +
 +=== ExtUtils::Install module 이용 ===
 +<codeprism bash>
 +#!/bin/sh
 +
 +# Begin ~/bin/pml.sh
 +
 +# List of installed Perl Modules
 +
 +# 검색어가 없으면 사용법 출력
 +if [ -z "$1" ]; then
 +        echo "Usage: $(basename $0) [pattern]"
 +        echo "Example: $(basename $0) build"
 +        exit 1
 +fi
 +
 +QUERY=$1
 +
 +echo "---- Searching installed Perl modules for: $QUERY ----"
 +
 +# ExtUtils::Installed를 사용하여 설치된 모듈 목록과 버전을 출력
 +# grep -i를 사용하여 대소문자 구분 없이 검색
 +
 +perl -MExtUtils::Installed -e '
 +        my $inst = ExtUtils::Installed->new();
 +        foreach my $mod ($inst->modules()) {
 +                my $ver = $inst->version($mod) || "N/A";
 +                print "$mod | Version: $ver\n";
 +        }
 +' | grep --color=auto -E -i "$QUERY"
 +
 +# 일치하는 결과가 없으면
 +
 +if [ ${PIPESTATUS[1]} -ne 0 ]; then
 +        echo "Result: No Matching Modules found."
 +fi
 +
 +# End ~/bin/pml.sh</codeprism>
 +<codeprism cmd=true cmdout=2-10>
 +pml.sh text
 +---- Searching installed Perl modules for: text ----
 +Text::BibTeX | Version: 0.91
 +Text::Diff | Version: 1.45
 +Text::Glob | Version: 0.11</codeprism>
  
 +버전을 출력해주는 장점이 있음. \\
 +특정 모듈 설치전에는 사용하기 힘들다는 단점이 있음.
 ==== 설치된 Python3 Module 목록 확인 ==== ==== 설치된 Python3 Module 목록 확인 ====
  
줄 172: 줄 233:
 ---- ----
 ==== PS1 설정 ==== ==== PS1 설정 ====
 +일반사용자
 +<codeprism bash>\[\033[01;34m\]\u\[\033[00m\]@\[\033[01;36m\]\h \[\033[01;34m\]\w\[\033[00m\] \$ </codeprism>
 +루트사용자
 +<codeprism bash>\[\033[01;35m\]\u\[\033[00m\]@\[\033[01;35m\]\h \[\033[01;37m\]\w \[\033[01;31m\]# \[\033[00m\]</codeprism>
  
-=== 최초 === 
  
-++++ 많이 지저분하고 번로움 +=== 2차 개선 === 
-<code lang=bash cmd=true user=root+++++ 아닌데 쓸데없이 길어짐
-touch $LFS/etc/lfs-chroot</code>\\ +<code bash> 
-~/.bashrc\\ +PS1_ROOT='\[$(tput setaf 203)\][ \[$(tput sgr0)\]\w \[$(tput setaf 203)\]] \[$(tput sgr0)\]\$\n' 
-<code lang=bash> +PS1_USER='\[$(tput setaf 75)\]\[$(tput sgr0)\]\\[$(tput setaf 75)\]\[$(tput sgr0)\]\$\n' 
-if -f /etc/lfs-chroot ]; then +PS1_HEAD='\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h ' 
-  PS1='\[$(tput setaf 75)\]<LFS> \[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\\[$(tput setaf 75)\]\\[$(tput sgr0)\]\$\n'+if [ "$(awk '$5=="/" {print $1}' </proc/1/mountinfo)" != "$(awk '$5=="/" {print $1}' </proc/$$/mountinfo)" ] ; then 
 +    if [ $(id -u) -eq 0 ] ; then 
 +        PS1="<Chroot>${PS1_HEAD}${PS1_ROOT}" 
 +    else 
 +        PS1="<Chroot>${PS1_HEAD}${PS1_USER}" 
 +    fi
 else else
-  PS1='\[$(tput setaf 75)\]\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h \[$(tput setaf 75)\]\w \[$(tput sgr0)\]\$\n' +    if [ $(id -u) -eq 0 ; then 
-fi</code>\\+        PS1="${PS1_HEAD}${PS1_ROOT}" 
 +    else 
 +        PS1="${PS1_HEAD}${PS1_USER}" 
 +    fi 
 +fi 
 +</code>
 ++++ ++++
- 
 === 1차 개선 === === 1차 개선 ===
  
줄 204: 줄 277:
 </code> </code>
 ++++ ++++
 +=== 최초 ===
  
-=== 2차 개선 === +++++ 많이 지저분하고 번거로움 | 
- +<code lang=bash cmd=true user=root> 
-<code bash> +touch $LFS/etc/lfs-chroot</code>\\ 
-PS1_ROOT='\[$(tput setaf 203)\][ \[$(tput sgr0)\]\w \[$(tput setaf 203)\]] \[$(tput sgr0)\]\$\n' +~/.bashrc\\ 
-PS1_USER='\[$(tput setaf 75)\]\[$(tput sgr0)\]\\[$(tput setaf 75)\]\[$(tput sgr0)\]\$\n' +<code lang=bash> 
-PS1_HEAD='\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h ' +if -f /etc/lfs-chroot ]; then 
-if [ "$(awk '$5=="/" {print $1}' </proc/1/mountinfo)" != "$(awk '$5=="/" {print $1}' </proc/$$/mountinfo)" ] ; then +  PS1='\[$(tput setaf 75)\]<LFS> \[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\\[$(tput setaf 75)\]\\[$(tput sgr0)\]\$\n'
-    if [ $(id -u) -eq 0 ] ; then +
-        PS1="<Chroot>${PS1_HEAD}${PS1_ROOT}" +
-    else +
-        PS1="<Chroot>${PS1_HEAD}${PS1_USER}" +
-    fi+
 else else
-    if [ $(id -u) -eq 0 ; then +  PS1='\[$(tput setaf 75)\]\[$(tput setaf 229)\]\u\[$(tput setaf 199)\]@\[$(tput setaf 215)\]\h \[$(tput setaf 75)\]\w \[$(tput sgr0)\]\$\n' 
-        PS1="${PS1_HEAD}${PS1_ROOT}" +fi</code>\\ 
-    else +++++
-        PS1="${PS1_HEAD}${PS1_USER}" +
-    fi +
-fi +
-</code> +
 ---- ----
 ==== Debian 설치 후 추가적인 사항 ==== ==== Debian 설치 후 추가적인 사항 ====
  • linuxfromscratch.1766065025.txt.gz
  • 마지막으로 수정됨: 2025/12/18 13:37
  • 저자 baecy