{"id":70382,"date":"2023-09-24T14:20:05","date_gmt":"2023-09-24T06:20:05","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=70382"},"modified":"2023-09-24T14:20:05","modified_gmt":"2023-09-24T06:20:05","slug":"pushd-and-popd","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/pushd-and-popd.html","title":{"rendered":"\u9ad8\u6548\u7684\u6d4f\u89c8 Linux \u76ee\u5f55\u7ed3\u6784\uff1apushd\u548cpopd\u547d\u4ee4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u6709\u65f6\u5019\uff0c\u901a\u8fc7\u547d\u4ee4\u6765\u5728 Linux \u6587\u4ef6\u7cfb\u7edf\u5bfc\u822a\u662f\u4e00\u4ef6\u975e\u5e38\u75db\u82e6\u7684\u4e8b\u60c5\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u4e00\u4e9b\u65b0\u624b\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4e3b\u8981\u4f7f\u7528cd\uff08\u6539\u53d8\u76ee\u5f55\uff09\u547d\u4ee4\u5728 Linux \u6587\u4ef6\u7cfb\u7edf\u4e4b\u95f4\u79fb\u52a8\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\u5728
\n\u5728\u8fd9\u4e2a\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u4e24\u4e2a\u76f8\u5173\u7684\u547d\u4ee4\uff1apushd\u548cpopd\uff0c\u4f7f\u7528\u5b83\u4eec\u53ef\u4ee5\u9ad8\u6548\u7684\u6d4f\u89c8 Linux \u76ee\u5f55\u7ed3\u6784\u3002\u8fd9\u4e24\u4e2a\u547d\u4ee4\u5728\u5927\u591a\u6570 shell \uff0c\u6bd4\u5982 bash\u3001tcsh \u4e2d\u90fd\u5b58\u5728\u3002<\/p>\n

pushd \u548c popd \u547d\u4ee4\u5728 Linux \u7cfb\u7edf\u4e2d\u5982\u4f55\u5de5\u4f5c<\/strong><\/div>\n

pushd\u548cpopd\u547d\u4ee4\u6839\u636e \u2018LIFO\u2019\uff08\u540e\u8fdb\u5148\u51fa\uff09\u539f\u5219\u5de5\u4f5c\u3002\u5728\u8fd9\u4e2a\u539f\u5219\u4e4b\u4e0b\uff0c\u53ea\u6709\u4e24\u4e2a\u64cd\u4f5c\u662f\u5141\u8bb8\u7684\uff1a\u628a\u4e00\u4e2a\u76ee\u5f55\u538b\u5165\u6808\uff0c\u4ee5\u53ca\u628a\u4e00\u4e2a\u76ee\u5f55\u5f39\u51fa\u6808\u3002<\/p>\n

pushd\u547d\u4ee4\u4f1a\u589e\u52a0\u4e00\u4e2a\u76ee\u5f55\u5230\u6808\u9876\uff0c\u800cpopd\u547d\u4ee4\u4f1a\u4ece\u6808\u9876\u79fb\u9664\u4e00\u4e2a\u76ee\u5f55\u3002<\/p>\n

\u4e3a\u4e86\u663e\u793a\u76ee\u5f55\u6808\u4e2d\uff08\u6216\u5386\u53f2\uff09\u7684\u76ee\u5f55\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u5c55\u793a\u7684dirs\u547d\u4ee4\uff1a<\/p>\n

$ dirs\r\n\u6216\r\n$ dirs -v\r\n<\/pre>\n

\"\u5728<\/p>\n

dirs- \u663e\u793a\u4f4d\u4e8e\u76ee\u5f55\u6808\u4e2d\u7684\u76ee\u5f55<\/em><\/p>\n

pushd\u547d\u4ee4\uff1a\u5c06\u4e00\u4e2a\u76ee\u5f55\u8def\u5f84\u6dfb\u52a0\u5230\uff0f\u653e\u5165\u76ee\u5f55\u6808\uff08\u5386\u53f2\uff09\u4e2d\uff0c\u4e4b\u540e\uff0c\u4f60\u53ef\u4ee5\u6d4f\u89c8\u4f4d\u4e8e\u76ee\u5f55\u6808\uff08\u5386\u53f2\uff09\u4e2d\u7684\u4efb\u610f\u76ee\u5f55\u3002\u5f53\u628a\u4e00\u4e2a\u65b0\u7684\u76ee\u5f55\u5165\u6808\u65f6\uff0c\u4f1a\u6253\u5370\u51fa\u5f53\u524d\u4f4d\u4e8e\u6808\u4e2d\u7684\u6240\u6709\u76ee\u5f55\u3002<\/p>\n

\u4e0b\u9762\u8fd9\u4e9b\u547d\u4ee4\u4f1a\u5c55\u793a\u8fd9\u4e2a\u547d\u4ee4\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff1a<\/p>\n

$ pushd  \/var\/www\/html\/\r\n$ pushd ~\/Documents\/\r\n$ pushd ~\/Desktop\/\r\n$ pushd \/var\/log\/\r\n<\/pre>\n

\"\u5728<\/p>\n

pushd-\u6dfb\u52a0\u65b0\u76ee\u5f55\u5165\u6808<\/em><\/p>\n

\u6839\u636e\u4e0a\u9762\u8f93\u51fa\u7684\u76ee\u5f55\u6808\u53ef\u77e5\uff08\u76ee\u5f55\u7d22\u5f15\u6309\u5012\u5e8f\u6392\u5217\uff09\uff1a<\/p>\n