store a variable in linux [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I was trying to create variables in my bash shell which I could use whenever I wanted. More specifically, I wanted to create a variable which could store the path to a folder, example:
mypath = `pwd`
However, I can't do the following:
cd $mypath
How can I resolve this? Also, I want to store this variable so I can use after I restart my system. Do I store this in the .bashrc file?

Don't use spaces in assignment, ie
mypath=`pwd`

Furthermore, if you want your variables to be globally available you can use the export command. Example: export mypath="pwd".
If you want the variables to persist after reboot, then you do need to add it to ~/.bashrc.
You can do this with nano ~/.bashrc and adding export mypath="pwd" to the end of the file

Related

Bash 'export environment variable [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
New kali linux terminal starts with a bash error:
bash: ‘export: command not found
I think I messed up my bash environment when workin on a jsnode installation and do not know how to fix it.
I think I need to fix my environment variable, but do not know where that is in Kali. Appreciate any help.
There seems to be a typo in a command. It should be export but instead it's ‘export. The errant character is Unicode U+2018, LEFT SINGLE QUOTATION MARK.
The first place to look is your .bashrc, then depending on your OS, .profile or .bash_profile, then any number of other Bash startup scripts that might get called like .bash_functions, or higher up the chain like /etc/bash.bashrc.

Create a shell script with a shell script [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm creating a script which create file and insert content using
cat > /etc/file <<END
FILE CONTENT
END
It works for most files but it doesn't work when file content have shell commands in it.
I tried with the echo command but i have the same problem.
Why does it execute commands ?
The file's content includes $variables wich are expanded. To avoid variable expansion, I had to use single-quote escapes 'END'.

Cant use node.js after install [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
After I have installed node, it works. I quit terminal and then I can't use node command in bash. Would anyone know why this is happening? Its rather infuriating. I think it may be something to do with the $PATH variable not being initialised in the right order or not at all.
I followed the 1st option https://gist.github.com/isaacs/579814
Thanks to #DavidWeldon and #Vinayak Mishra
Add export PATH=$HOME/local/bin:$PATH in ~/.bash_profile and source ~/.bash_profile or exit and open new terminal. Create ~/.bash_profile it isn't available already.
If there is a problem with the $PATH, you can check it with:
echo $PATH && source ~/.profile && echo $PATH
If there are difference, files are not being called in the right order. Take a look at this.

Cygwin - setting up $PATH [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I've found it's really difficult to setup path variable. I've tried a lot of combinations but nothing works at all. My over 1h work results are but as you see on screenshot (http://puu.sh/33n0X.png )
echo $PATH
give strange directory and
rm -rf k.txt
doesn't work at all. Does anyone has idea what is wrong there? I'm totally confused about it
If you want something a little more "normal", you can suppress the current PATH being appended, and just build your own.
In your ~/.bash_profile, put something to this effect
PATH=/bin
and if you want System32 you can add it as well
PATH=/bin:${TMP%U*}windows/system32
Example

What are circular symlinks in Unix-like systems used for? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I was browsing a directory on a Linux machine, and when doing a detailed listing I noticed that a link is pointing to itself, for example:
somelink -> /path/to/directory/somelink
I am wondering what is the reason for doing such a thing?
If the somelink is in /path/to/directory then this is an invalid symlink. If you try to access it, the filesystem will give you an error (probably something like too many levels of symbolic links*). It could have been a typo (or some other mistake) when it was created, or the symlink got moved somehow and ended up linking to itself.
There's no good reason for a circular symlink. Most probably, it was created by accident.

Resources