【问题标题】:Cat the contents of a .txt file to .bash_profile将 .txt 文件的内容转换为 .bash_profile
【发布时间】:2016-05-25 02:18:08
【问题描述】:

我正在我的保管箱上设置一个 .txt 文件,该文件将在我的笔记本电脑和台式机之间自动同步。此 .txt 文件包含我希望在这些计算机之间保持同步的 .bash_profile 的所有内容,包括当前看起来像这样的别名:

配置文件配置

别名 bprofud="cat ~/Dropbox/profile.txt > ~/.bash_profile"

(其中“bprofud”== bash 配置文件更新的简称)

这里的想法是,为了在两台计算机上保留对我的 bash 配置文件的任何更改,我只需在我的保管箱中编辑文本文件,然后在每台计算机上运行“bprofud”。

但这不起作用。我不确定为什么。它只是每次写入一个新的 .bash_profile 而不是覆盖之前的。

我正在运行最新版本的 MacOSX。

知道可能出了什么问题吗?

【问题讨论】:

  • 链接文件比运行命令重写文件更容易吗? ln -s ~/Dropbox/profile.txt ~/.bash_profile
  • 我不知道您所说的“它只是每次都写入一个新的 .bash_profile 而不是覆盖以前的”是什么意思,但是 source 会不会更容易共享文件到你的.bash_profile?

标签: linux macos bash alias profile


【解决方案1】:

您可以简单地让您的个人资料来源该保管箱文件:

[[ -r ~/Dropbox/profile.txt ]] && . ~/Dropbox/profile.txt

【讨论】:

    【解决方案2】:

    原因是一个简单的拼写错误;)

    alias bprofud="cat ~/Dropbox/profile.txt > ~/.bash_profle"
    

    应该是

    alias bprofud="cat ~/Dropbox/profile.txt > ~/.bash_profile"
    

    你只是错过了“i”

    【讨论】:

    • 很好,但现在我必须投票结束这个问题。 ;-)
    • 我真的想过你的问题,需要时间看看^^
    猜你喜欢
    • 2020-08-31
    • 1970-01-01
    • 1970-01-01
    • 2017-07-13
    • 1970-01-01
    • 2021-12-24
    • 2017-02-09
    • 2017-09-23
    • 2014-06-11
    相关资源
    最近更新 更多