General :: Variable Expansion In .bashrc Not Working?
Feb 21, 2011
In my .bashrc file, I am attempting to set JAVA_PATH to a local path, using the HOME environment variable or '~' symbol as shown in the following examples.Using ${HOME}
When I attempt to use ${JAVA_HOME} in a my ${PATH} javec is not found. To debug it, I tried a simple ls command:
ls ${JAVA_HOME}
and get the following error:
ls: ${HOME}/Software/java/jdk1.6.0_24/: No such file or directory
Using '~': Trying to use '~' symbol as follows:
export JAVA_PATH='~/Software/java/jdk1.6.0_24'
the ls command results in the same error, however javac is found.I prefer the '~' symbol anyway, but would like to understand why the ls command does not work for either, and why it seems as though ${HOME} is not being expanded.
I've searched google, tldp.org and these forums and I can't seem to find an example of how this would work. I want #2 to work like #1. Any suggestions?
**Edit: I forgot to add, the values in VAR are not sequential and can have multiple digits. For example, VAR=13,17,10.
**Edit2: [URL] The bottom line of code in the first gray block of code shows that you cannot use variables in such an expansion:
Code:
#!/bin/bash a=1 b=5 echo {$a..$b}
But I'm looking for pasting the complete contents of a variable into these braces, not some portion of it...
What I am trying to accomplish is a way to read only the lines that have been added to the file mylog0 since the last time the script looped (5 seconds). I am open to new suggestions too, I have been stuck on this little script for a few hours already.
This script is intended to allow you to simultaneously run a command on a set of remote hosts in a single gnome-terminal tabbed window. It runs it through screen so if it's a long process it's immune to network failures.
The command string gets built ok, but when it comes to executing the gnome-terminal command, it chokes with
Quote:
Argument to "--command/-e" is not a valid command: Text ended before matching quote was found for ". (The text was '"ssh')
If you copy/paste the "Running: gnome-terminal" line, it works as expected.
I'm pretty sure the problem is with the commandline variable expansion, but dont know what else to try.
Another thing I'd like to be able to do is keep the shell open after the command finishes. Right now, I just get "screen terminated" and the gnome-terminal tab says bye-bye.
I plugged in a seagate expansion drive 1Tb into my linux server for backup purposes but it is unable to mount it. I can see the expansion drive in My computer but when I click on it, it says unable to mount, device already mounted or busy. Windows can read the hard disk with no problems. It is ntfs formatted. I installed ntfs kernel and fuse. Ntfs is displayed when I run cat /proc/filesystems. However it just can't mount the expansion drive.
After saving above changes, I enter the command: source ~/.bashrc Now if I do echo $PATH, the path shows both the old PLAY_HOME and new PLAY_HOME. This is really bad and messes up a lot of things in my project. This problem only goes away if I logout or reboot, a rather very long process. What is happening is that the old path is added to new path element and the old path includes the old path element you want to remove.
it says cant mount volume and wont recognize my seagate expansion drive after I had the seagate plugged in to a windows pc! It says something about using command line to fix it but I'm new to Linux and don't know what to do!
I am supposed to create an environment variable with the PRINTER variable, which should resolve to the word sales. Would the command be like this?: env PRINTER - NAME=SALES (is this the command to create that variable with resolving the word sales to it?)
I'd like a function in my .bashrc file that would allow me to pass text to it and echo the text to a specified file. I know it's simple as "echo 'text' >> file," but ideally, I would want to alias the function so I execute something like:
Code: user~ $ write 'this is a test' with "write" being the function, and 'this is a test' being echoed to the file. I hope I explained that well enough.
A cluster with a head node and compute nodes. An application with a couple of env variables (App_HOME, PATH) set in .profile (default shell sh). If I login to the head node/compute nodes on a terminal everything works fine. The correct env variables are set and the application works. However, when my application tries to do it, say ssh <compute node1> <application>, it appears the environment variables are not available. It only looks in the minimal /bin, /usr/bin type PATH. This tells that the .profile is not being read
can i use the value of one variable to generate a name for another variable? for example i want to use the counter from a "do while" loop to name and define a variable each time the loop executes. for example
objectnames1=`ls -a` objectnames2=`ls -a` etc.
i don't have a script yet but each time through the loop i intend to cd to a particular directory and then define a variable containing a list of each object in that directory as values. for the rest of the script to work, each variable generated has to be unique, and i can't think of a good way to accomplish this.
if using a value from one variable to name another isn't possible, can anyone think of a more elegant solution? i know limited syntax but i'm willing to read up...
I am trying to alter the character position of residue numbers above 999 in a pdb file.The following script is an attempt to:1) Get all unique pdb residue numbers (in column 5) using awk and assign it to a variable i.2) Loop through all the values in $i and if it is greater than 999, shift that number one character to the right using sed.However, the script only manages to alter the final residue numberCould anyone please advise how I can loop through all values in $i and shift it one character to the right?
#!/bin/bash # Script to alter position of residue number in pdb file for resid above 999 i=$(awk '{print $5}' wt-test.pdb | uniq)
I need to source the my /home/me/.bashrc file every time I "su -" to root. Is there any way to automate this? I cannot edit any thing in the root's environment as it is shared by people.
I am trying to include my directory /usr/sbin in it's serch path for executable files using an environment variable. Would the input be: PATH="/usr/sbin"? And also upon start up, my shell should create the PRINTER environment variable which should resolve to the word sales...would that input be: PRINTER="sales"? If someone could help me with these two questions,
The problem is I can't use $0 as reference because the script is only sourced not executed. I also don't want to hardcode the path because the location might change and there will be more copies. Is there an easy way to create this information from within the the sourced bashrc file? I use Gnu bash 2.05b on Suse Linux 9.
I have a problem with my script. The problem is the system keeps rebooting after I put the directory file in .bashrc. The intentional for putting the file in .bashrc is to run the script automatically after login as root, I don know why is this happen. It was working fine for the first time without putting the file in bashrc. I could break the loop after hitting the "ESC" key. would it be the script problems?
Here is my script count=20 while [ $count -gt 0 ];do sleep 1 echo Press ESC to break the operation ((count=count-1))
I have installed a software and set the variables in the .bashrc file to avoid setting them everytime I would like to run te software. Now I have installed a new software and would like to do the same thing in the .bashrc file.How can I add the path to the new software directory without affecting the first software path.