bash export command

后端 未结 8 1325
迷失自我
迷失自我 2020-12-16 11:44

I am encountering a strange problem with my 64bit Ubuntu - on the export command.

Basically, I have got a VM installation on Ubuntu on my Win7, and I am trying to pa

相关标签:
8条回答
  • 2020-12-16 12:19

    export is a Bash builtin, echo is an executable in your $PATH. So export is interpreted by Bash as is, without spawning a new process.

    You need to get Bash to interpret your command, which you can pass as a string with the -c option:

    bash -c "export foo=bar; echo \$foo"
    

    ALSO:

    Each invocation of bash -c starts with a fresh environment. So something like:

    bash -c "export foo=bar"
    bash -c "echo \$foo"
    

    will not work. The second invocation does not remember foo.

    Instead, you need to chain commands separated by ; in a single invocation of bash -c:

    bash -c "export foo=bar; echo \$foo"
    
    0 讨论(0)
  • 2020-12-16 12:22

    Probably because it's trying to execute "export" as an external command, and it's a shell internal.

    0 讨论(0)
  • 2020-12-16 12:25

    If you are using C shell -

    setenv PATH $PATH":/home/tmp"
    
    0 讨论(0)
  • 2020-12-16 12:25

    SHELL is an environment variable, and so it's not the most reliable for what you're trying to figure out. If your tool is using a shell which doesn't set it, it will retain its old value.

    Use ps to figure out what's really going on.

    0 讨论(0)
  • 2020-12-16 12:29

    change from bash to sh scripting, make my script work.

    !/bin/sh

    0 讨论(0)
  • 2020-12-16 12:29

    Follow These step to Remove " bash export command not found." Terminal open error fix>>>>>>

    open terminal and type : root@someone:~# nano ~/.bashrc

    After Loading nano: remove the all 'export PATH = ...........................' lines and press ctrl+o to save file and press ctrl+e to exit.

    Now the Terminal opening error will be fixed.........

    0 讨论(0)
提交回复
热议问题