LinuxÏÂÁÏÔʾÎļþµÄÍêÕû·¾¶
LinuxÏÂÁÏÔʾÎļþµÄÍêÕû·¾¶
ÔÚLinuxϵͳÖУ¬ÓÐʱÎÒÃÇÐèÒªÉó²éÎļþµÄÍêÕû·¾¶£¬ÒÔ±ã¾ÙÐвÙ×÷»ò¶¨Î»ÎļþλÖᣱ¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃLinuxÏÂÁîÀ´ÏÔʾÎļþµÄÍêÕû·¾¶£¬Í¬Ê±ÌṩÏêϸµÄ´úÂëʾÀý¡£
1. ʹÓÃrealpathÏÂÁî
realpathÏÂÁî¿ÉÒÔÓÃÀ´»ñÈ¡ÎļþµÄ¾ø¶Ô·¾¶£¬¼´ÍêÕû·¾¶¡£ÏÂÃæÊÇʹÓÃrealpathÏÂÁîµÄʾÀý£º
realpath ÎļþÃû
µÇ¼ºó¸´ÖÆ
ÀýÈ磬ÈôÊÇÎÒÃÇÐèÒªÉó²éÎļþÃûΪexample.txtµÄÍêÕû·¾¶£¬¿ÉÒÔÊäÈëÒÔÏÂÏÂÁ
realpath example.txt
µÇ¼ºó¸´ÖÆ
Ö´ÐиÃÏÂÁîºó£¬Öն˻áÊä³öexample.txtÎļþµÄÍêÕû·¾¶£¬ÀýÈç/home/user/documents/example.txt¡£
2. ʹÓÃreadlinkÏÂÁî
ÁíÒ»¸ö³£ÓõÄÏÂÁîÊÇreadlink£¬Ëü¿ÉÒÔÓÃÀ´ÏÔʾ·ûºÅÁ´½ÓËùÖ¸ÏòµÄÄ¿µÄÎļþµÄ·¾¶¡£Ê¾ÀýÈçÏ£º
readlink -f ÎļþÃû
µÇ¼ºó¸´ÖÆ
¼ÙÉèÎÒÃÇÓÐÒ»¸öÃûΪlink.txtµÄ·ûºÅÁ´½ÓÖ¸Ïòtarget.txtÎļþ£¬ÈôÊÇÎÒÃÇÏë»ñÈ¡target.txtÎļþµÄÍêÕû·¾¶£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
readlink -f link.txt
µÇ¼ºó¸´ÖÆ
Ö´ÐиÃÏÂÁîºó£¬Öն˻áÊä³ötarget.txtÎļþµÄÍêÕû·¾¶¡£
3. ʹÓÃpwdÏÂÁî
pwdÏÂÁîͨ³£ÓÃÓÚÏÔʾĿ½ñÊÂÇéĿ¼µÄ·¾¶£¬µ«ÍŽáfindÏÂÁҲ¿ÉÒÔÓÃÀ´ÏÔʾָ¶¨ÎļþµÄÍêÕû·¾¶¡£Ê¾ÀýÈçÏ£º
find `pwd` -name ÎļþÃû
µÇ¼ºó¸´ÖÆ
¼ÙÉèÎÒÃÇÏëÕÒµ½Ä¿½ñÊÂÇéĿ¼¼°Æä×ÓĿ¼ÏÂÃûΪexample.txtµÄÎļþ·¾¶£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ
find `pwd` -name example.txt
µÇ¼ºó¸´ÖÆ
Ö´ÐиÃÏÂÁîºó£¬Öն˻áÊä³öexample.txtÎļþµÄÍêÕû·¾¶¡£
½áÓï
ͨ¹ýÉÏÊöʾÀý£¬ÎÒÃÇÏàʶÁËÔÚLinuxϵͳÖÐÔõÑùʹÓÃrealpath¡¢readlinkºÍpwdÏÂÁîÀ´ÏÔʾÎļþµÄÍêÕû·¾¶¡£ÕâЩÏÂÁîÄܹ»×ÊÖúÎÒÃÇÀû±ãµØ²éÕÒÎļþµÄλÖ㬾ÙÐÐÏà¹Ø²Ù×÷¡£Ï£Íû±¾ÎĶÔÄúÓÐËù×ÊÖú£¡
ÒÔÉϾÍÊÇLinuxÏÂÁÏÔʾÎļþµÄÍêÕû·¾¶µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡