簡體   English   中英

如何在Shell文件中更改pwd目錄?

[英]How to change pwd directory in Shell file?

我有這個外殼文件,應該從另一個目錄中提取數據,但是它嘗試使用“ $ pwd”從當前目錄中提取文件。 我如何指定一個文件夾來提取這些文件,例如,它來自/ home / gnssb / Desktop / Data而不是/ home / gnssb / Desktop / Data / shell_scripts

    #!/bin/sh

    ORIG_DIR=$(pwd)
    basedir="../"

    year=2016;
    init_month=01;
    end_month=01;
    init_date=01;
    end_date=26;

    casesinp="${ORIG_DIR}/./cases-inp"

嘗試添加cd

#!/bin/sh

ORIG_DIR=$(pwd)
basedir="../"

year=2016;
init_month=01;
end_month=01;
init_date=01;
end_date=26;

casesinp="${ORIG_DIR}/./cases-inp"

cd ${ORIG_DIR}/..
NEWPWD=$(pwd)

# NEWPWD would be level above shell-scripts now

# now, whatever commands following that gave you the wrong data before
# but on NEWPWD

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM