'Shell'에 해당되는 글 2건

  1. 2011.09.15 [Linux][Shell] Cleaning PATH environment variable.
  2. 2009.10.15 [Bash] Shell setup files

[Linux][Shell] Cleaning PATH environment variable.

Domain/Linux 2011.09.15 11:04

With using terminal for a long time, PATH variable tends to be longer and longer due to duplicated path.
Here is simple sample script - with Perl - to resolve this.

# remove duplication at give PATH-format-string
unique_path() {
perl -w -e '
    my %path_hash;
    exit unless (defined $ARGV[0]);
    foreach $p (split (/\:/, $ARGV[0])) {
        unless (defined $path_hash{$p}) {
            $path_hash{$p} = 1;
            push @newpath, $p;
        }
    }
    print join ":", @newpath;
' $1
}
...(skip)...
PATH=$(unique_path "$PATH")
...(skip)

Done :-).

신고
tags : Shell
Trackback 0 : Comment 0

[Bash] Shell setup files

Domain/Linux 2009.10.15 19:51

[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]
 

From top to bottom

/etc/profile
.bash_profile [ -> .bash_login -> .profile ] : if '.bash_profile' doesn't exist the '.bash_login'...
.bashrc : whenever an interactive shell is started.
.bash_logout : when the login shell is existed.

신고
tags : bash, Linux, Shell
Trackback 0 : Comment 0

티스토리 툴바