1. 程式人生 > 其它 >shell程式設計例子(2),持續更新中

shell程式設計例子(2),持續更新中

技術標籤:linuxshell

1.當前shell切換到指定目錄:用source執行:source 1.sh

#!/bin/bash
pwd
cd /home/share.21/
pwd

執行結果:

2. 命令執行的結果賦值給變數

#!/bin/bash
cd /home/share.21/

current_dir1=`pwd`
current_dir2=$(pwd)

echo $current_dir1
echo $current_dir2

執行結果: