2016-06-12 49 views
0

大約一年前,我想編輯.bash_profile來添加一些文本,當我打開終端(我在Mac上使用最新的操作系統)。今天,我想改變那些文字,只是發現我找不到我編輯的原始文件。看起來MacPorts移動了一些東西,因爲我可以在.bash_profile文件上添加文本,但去年我創建的文本不在文件中,我無法刪除它。尋找缺少的.bash_profile

這是我目前的.bash_profile:

export PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}" 

## 
# Your previous /Users/nathanielhoffman/.bash_profile file was backed up as /Users/nathanielhoffman/.bash_profile.macports-saved_2015-10-11_at_12:31:11 
## 

# MacPorts Installer addition on 2015-10-11_at_12:31:11: adding an appropriate PATH variable for use with MacPorts. 
export PATH="/opt/local/bin:/opt/local/sbin:$PATH" 
# Finished adapting your PATH environment variable for use with MacPorts. 

你問之前,是的,我的.profile和.bashrc中進行檢查。空空如也。 MacPorts表示它也沒做任何備份配置文件。在這個文件的末尾添加諸如「echo」hello world「'這樣的文本將在神祕文本源下添加文本。

有沒有一種方法可以找出我的電腦在第一次打開shell時讀取的文件?提前致謝!

+0

的MacPorts通常會備份你的.bash_profile製作的文件進行任何更改,如'之前.bash_profile.macports-saved_2015-01-20_at_19:08:40' –

+0

問題是,該文件中的唯一行是: –

+0

PATH =「/ Library/Frameworks/Python.framework/Version/3.5/bin:$ {PATH}」 export PATH –

回答

1

有沒有一種方法可以計算出我的電腦在第一次打開shell時讀取的是哪個文件?

您可以設置PS4這是在調試-x運行bash時使用:

PS4='+ $BASH_SOURCE:$LINENO: ' bash -xlic "" 

這會給你一個什麼樣的文件都被包括命令和行號開始bash作爲交互式登錄時的軌跡貝殼。

-x痕跡-l是登錄shell,-i是交互式,-c ''是要運行的命令。

的信息,請參閱man bashPS4

PS4 The value of this parameter is expanded as with PS1 and the value 
      is printed before each command bash displays during an execution trace. 
      The first character of PS4 is replicated multiple times, as necessary, 
      to indicate multiple levels of indirection. The default is ``+ ''. 
+1

這導致我通過我的/ etc /文件夾進行一次冒險冒險。在查看名稱中包含「bash」或「profile」的所有內容後,我終於注意到一個名爲「motd」的文件,我認爲它代表「當天的訊息」。低看,我正在尋找的文本在那裏。謝謝。 –