Adding path

7 views
Skip to first unread message

Kevin Kangik Cho

unread,
Dec 19, 2012, 6:27:51 PM12/19/12
to linux-f...@googlegroups.com
path
'내가 아는 위치' 라고 생각하면 된다.

예를 들어서
대한민국/서울특별시/종로구/명륜동/우리집/내컴퓨터

가 있을 때
서울특별시에서 '내컴퓨터'라고 하면 서울특별시폴더에는 내컴퓨터가 없기때문에
인식하지 못한다.

하지만
내가 아는 위치(path)에 
대한민국/서울특별시/종로구/명륜동/우리집 등록

하면
어느나라 어느도에서도 '내컴퓨터'가 인식된다 




.bashrc 파일을 열어서
PATH=$PATH:/대한민국/서울특별시/종로구/명륜동/우리집



와 같이 입력한다.
eg
PATH=$PATH:/usr/local/bin





저장 / 종료 후 터미널 재실행.




***subdirectory까지 추가하 기

At the end of your script, put the line:
PATH=${PATH}:$(find ~/code -type d | tr '\n' ':' | sed 's/:$//')



This will append every directory in your ~/code tree to the current path. I don't like the idea myself, preferring to have only a couple of directories holding my own executables and explicitly listing them, but to each their own.

If you want to exclude all directories which are hidden, you basically need to strip out every line that has the sequence "/." (to ensure that you don't check subdirectories under hidden directories as well):

PATH=${PATH}:$(find ~/code -type d | sed '/\/\\./d' | tr '\n' ':' | sed 's/:$//')



This will stop you from getting directories such as ~/code/level1/.hidden/level3/ (i.e., it stops searching within sub-trees as soon as it detects they're hidden). If you only want to keep the hidden directories out, but still allow non-hidden directories under them, use:

PATH=${PATH}:$(find ~/code -type d -name '[^\.]*' | tr '\n' ':' | sed 's/:$//')



This would allow ~/code/level1/.hidden2/level3/ but disallow~/code/level1/.hidden2/.hidden3/ since -name only checks the base name of the file, not the full path name.


Reply all
Reply to author
Forward
0 new messages