I need to add google-cloud-sdk in PATH in ubuntu-16.
I try
gedit ~/.profile
inside .profile
export PATH = "$PATH:/$HOME/google-cloud-sdk"
but it give me error that
bash: export '=' : not a valid identifier
I am new to this. Please help.
As #mwweb correctly pointed out, assignments in BASH (and most other shells) cannot have spaces around the = operator. Just remove them:
export PATH="$PATH:$HOME/google-cloud-sdk"
Note that you likely want to remove the leading / from the path as well.
Related
Im testing my code for automation of the installation of a software
In bashrc file below:
# User specific aliases and functions
export JAVA_HOME=/opt/jdk-9.0.1
export JRE_HOME=/opt/jdk-9.0.1/jre
export SCALA_HOME=/opt/scala-2.13.0
export PATH=$PATH:/opt/jdk-9.0.1/bin:/opt/jdk-9.0.1/jre/bin
Here im trying to add $SCALA_HOME/bin to PATH.
this is the required output:
`export PATH=$PATH:/opt/jdk-9.0.1/bin:/opt/jdk-9.0.1/jre/bin:/opt/scala-2.13.0`
`sed -i '1n;/^export PATH/i\export SCALA_HOME=/opt/scala-2.13.0' .bashrc`
the above code worked to append SCALA_HOME above path but for appending in the same line im not able to do
`sed -i "s/\"export PATH\":.*,$/\"export PATH\": \":$SCALA_HOME/bin\",/g" .bashrc
sed: -e expression #1, char 40: unknown option to `s'`
please help me get the correct sed command to append SCALA_HOME in the PATH
You can use this:
sed '/export PATH/ s/$/:\$SCALA_HOME\/bin/' .bashrc
's/\(export PATH=.*\)/\1:\$SCALA_HOME\/bin/'
To go through your expression:
s/\"export PATH\":.*,$/\"export PATH\": \":$SCALA_HOME/bin\",/g"
The \"export will look for "export in your file. Why do you expect a double quote before the export? It isn't there in the example. Likewise, PATH\": in the pattern will look for PATH": in the file. That double quote isn't there either. Your ,$ at the end of your pattern will also prevent it from matching anywhere.
While installing UIMA I got this steps in readme file
* Set JAVA_HOME to the directory of your JRE installation you would like to use for UIMA.
* Set UIMA_HOME to the apache-uima directory of your unpacked Apache UIMA distribution
* Append UIMA_HOME/bin to your PATH
* Please run the script UIMA_HOME/bin/adjustExamplePaths.bat (or .sh), to update
paths in the examples based on the actual UIMA_HOME directory path.
This script runs a Java program;
you must either have java in your PATH or set the environment variable JAVA_HOME to a
suitable JRE.
I opened /etc/environment and perfomed this changes:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/UIMA_HOME/bin"
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386"
UIMA_HOME="/root/Desktop/karim/software/UIMA/UIMA_SDK_1.4.5"
after that executed:
UIMA/UIMA_SDK_1.4.5/bin# ./documentAnalyzer.sh
which gave this error:
./documentAnalyzer.sh: 2: .: Can't open /bin/setUimaClassPath.sh
documentAnalyzer.sh code :
#!/bin/sh
. "$UIMA_HOME/bin/setUimaClassPath.sh"
if [ "$JAVA_HOME" = "" ];
then
JAVA_HOME=$UIMA_HOME/java/jre
fi
"$JAVA_HOME/bin/java" -cp "$UIMA_CLASSPATH" -Xms128M -Xmx900M "-Duima.home=$UIMA_HOME" "-Duima.datapath=$UIMA_DATAPATH" -DVNS_HOST=$VNS_HOST -DVNS_PORT=$VNS_PORT "-Djava.util.logging.config.file=$UIMA_HOME/Logger.properties" com.ibm.uima.reference_impl.application.docanalyzer.DocumentAnalyzer
What is the mistake here? I guess I set environment variable correctly
I think the answers given about adding the $ to the variable UIMA_HOME in your PATH variable are correct, but, I think you are also lacking the EXPORT command for your variables.
Look, after you set their values, you should also writhe this in /etc/environment:
export UIMA_HOME
export JAVA_HOME
export PATH
That way, you would be able to use them later (always remember to fix the PATH variable with the $UIMA_HOME as well).
If this does not work, try rebooting your computer after setting the variables as I said.
In the case that does not work either, try repeating the process and in a console (after doing everythin all over again) try using the following command:
source /etc/environment
Fianlly, if that does not work, try setting the variables in the file called /etc/profile (do the same process: setting the varialbes and exporting them), and this should work.
The order of variable assignments in your /etc/environment is wrong; in order to use $UIMA_HOME in the PATH=..., you have to define UIMA_HOME afore, e. g.
UIMA_HOME="/root/Desktop/karim/software/UIMA/UIMA_SDK_1.4.5"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$UIMA_HOME/bin"
JAVA_HOME="/usr/lib/jvm/java-7-openjdk-i386"
I am trying to create a .bashrc file with the android dev kit in Ubuntu. Only problem is, when i edit/ add to the bashrc file, I get a "syntax error near unexpected token newline". I posted the code where the error is, specifially between android SDK home token and android NDK token. Thanks for the help
#Android SDK Home
export ANDROID_SDK=</Documents/adt-bundle-linux-x86_64-20140702>
#ANDROID NDK Home
export NDK=~/android-ndk-r10b
export PATH=$PATH: $ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
I guess that you have read something like this in a guide somewhere:
Add the following lines to your .bashrc file:
export ANDROID_SDK=<path/to/your/SDK>
# etc.
The < > are meant as placeholders, i.e. <replace this bit>. You don't need to put the path inside them, in fact you should remove them, as they are invalid syntax (which is causing the error you mention). Also, you should remove the space between $PATH: $ANDROID_SDK later on:
#Android SDK Home
export ANDROID_SDK="/Documents/adt-bundle-linux-x86_64-20140702"
#ANDROID NDK Home
export NDK="$HOME/android-ndk-r10b"
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools"
To be more specific, the error was caused by the > at the end of the export line, as this means "redirect the output of the command to the following file descriptor". Bash is then expecting the name of a file descriptor but all it found was a newline. The < at the beginning is also problematic, as it means "redirect the contents of this file descriptor to the command", which won't do anything useful in your case. See this wiki page for more details.
By the way, there's no harm in using double quotes, in fact, they're encouraged. Using them means that word splitting will not occur in case the name of a directory contains a space. I've added some around your assignments and changed ~ to $HOME, so that it will still do what you want (the ~ will be interpreted literally within double quotes, whereas $HOME will expand to the path of your home directory).
Angle brackets are not valid to use this way.
I'm trying to set system variable in ubuntu shell.
export VARIABLE=!password!
output:
-bash: !password!': event not found
so I tried with quotes:
export VARIABLE="!password!"
output:
-bash: !password!: event not found
or even
export VARIABLE='!password!'
with no output, but when i tried to see the variable I get:
VARIABLE='!password!'
which is not the desired one.
I also tried with backslashes here and there, but with no success. Please help, the task is to create system variable with password: !password!
(starting and ending with exclamation marks.)
If you do:
VARIABLE='!bla!'
And then
echo $BLA
you get
!bla!
which is what you seem to describe as the wanted result.
To make it available to subshells, don't forget to add export to the above.
In my .sh file, I have this, cp $file $SOME_PATH, while $SOME_PATH is exported as export SOME_PATH="~/path/to/path/". But when I ran this .sh file, I got error message saying like no such "~/path/to/path/" exists.
I replaced ~ as $HOME, then the error was gone.
So what's up here with the tilde?
Thanks in advance.
use
SOME_PATH=~/path/to/path/
if you path have spaces, quote it
SOME_PATH=~/"path with spaces"
Remove the quotation marks on your export:
export SOME_PATH=~/path/to/path/