Stackoverflow.com-r Command Not Found - Bashrc Bash_profile
Stackoverflow.com-r Command Not Found - Bashrc Bash_profile
bash_profile
stackoverflow.com /questions/11616835/r-command-not-found-bashrc-bash-profile
I have windows, using Cygwin, trying to set JAVA_HOME permanently through my .bashrc file.
.bashrc:
export PATH="$JAVA_HOME/bin:$PATH"
export JAVA_HOME=$JAVA_HOME:"/cygdrive/c/Program Files
(x86)/Java/jdk1.7.0_05"
.bash_profile:
if [ -f ~/.bashrc ];
then
source ~/.bashrc
fi
running cygwin:
I am not sure if I took the commands from a tutorial that was meant for another system or if I am missing a step.
Or whitespace is causing my commands not to run properly.
I've looked at multiple similar questions but I haven't found one where the question has my error exactly.
My home path:
$ echo $HOME
/cygdrive/c/Users/jhsu
$ echo ~
/cygdrive/c/Users/jhsu/
15 Answers
1/8
up vote 214 down vote When all else fails in Cygwin...
accepted
Try running the dos2unix command on the file in question.
The dos2unix command modifies newline characters so they are Unix / Cygwin
compatible.
If you need to keep the original file, you should back it up first.
Note for Mac users: The dos2unix command does not exist on Mac OS X.
Check out this answer for a variety of solutions using different tools.
If you open a file with Notepad and all the lines run together, try
unix2dos
filename .
up vote 79 For those who don't have dos2unix installed (and don't want to install it):
down vote
Remove trailing \r character that causes this error:
sed -i 's/\r$//'
filename
Explanation:
Option -i is for in-place editing, we delete the trailing \r directly in the input file. Thus be
careful to type the pattern correctly.
Michael P. Bazos
11k22839
2/8
up set -o
vote I am using cygwin and Windows7, the trick was NOT to put the igncr into your .bashrc but put
32 the whole SHELLOPTS into you environment variables under Windows. (So nothing with unix / cygwin...) I
down think it does not work from .bashrc because "the drops is already sucked" as we would say in german. ;-)
vote So my SHELLOPTS looks like this
braceexpand:emacs:hashall:histexpand:history:igncr:interactive-comments:monitor
up vote 22 If you are using a recent Cygwin (e.g. 1.7), you can also start both your .bashrc and
down vote .bash_profile with the following line, on the first non commented line:
This will force bash to ignore carriage return ( \r) characters used in Windows line separators.
See http://cygwin.com/ml/cygwin-announce/2010-08/msg00015.html.
Ael Ombreglace
84449
bash -x -o igncr
script.sh
user1010997
34037
3/8
up vote 15 down vote SUBLIME TEXT
Easy as that!
Alvaro Joao
3,82741638
up vote 14 For WINDOWS users with Notepad++ (checked with v6.8.3) you can correct the specific file using
down vote the option - Edit -> EOL conversion -> Unix/OSX format
up vote 3 down vote folks who use notepad++(6.8.1) to ship shell scripts from windows to linux.
set the following in notepad ++ Edit -> EOL Conversion -> Unix/OSX format
viru
694
up vote 3 down As per this gist, the solution is to create a ~/.bash_profile (in HOME directory) that
vote contains:
export
SHELLOPTS
set -o igncr
up The error:
vote 3
down
vote '\r': command not found
4/8
is caused by shell not able to recognise Windows-like CRLF line endings ( 0d 0a) as it expects only LF
(0a).
Git
If you using Git on Windows, make sure you selected ' Checkout as-is' during setup. Then make sure
git config --global core.autocrlf
that you run: false , so Git will not perform any
conversions when checking out or committing text files.
dos2unix
If you're not using Git, you simply need to convert these affected files/scripts back into Unix-like line
endings (LF), either by:
dos2unix
~/.bashrc
Ex/Vim editor + tr
If you've Vim installed, the following command should correct the files:
tr
or:
sed
recode
5/8
The following aliases can be useful (which replaces dos2unix command):
alias unix2dos='recode
lat1:ibmpc'
alias dos2unix='recode
ibmpc:lat1'
perl
The following perl command can convert the file from DOS into Unix format:
tofrodos
On Linux, like Ubuntu which doesn’t come standard with either dos2unix or unix2dos, you can install
sudo apt-get install
tofrodos package ( tofrodos ), and define the following aliases:
alias
dos2unix=’fromdos’
alias unix2dos=’todos’
Vagrant
If you're using Vagrant VM and this happens for provisioning script, try setting binary option to true:
6/8
up vote 2 down I had the same problem. Solution: I edit the file with pspad editor, and give it a unix format
vote (Menu - Format -> UNIX)
I believe you can set this format to your file with many other editors
israel
211
up vote 2
down vote
For the Emacs users out there:
1. Open the file
2. M-x set-buffer-file-coding-system
3. Select "unix"
This will update the new characters in the file to be unix style. More info on "Newline
Representation" in Emacs can be found here:
http://ergoemacs.org/emacs/emacs_line_ending_char.html
Note: The above steps could be made into an Emacs script if one preferred to execute this from
the command line.
user2548343
22118
Danny Schoemann
8691430
7/8
up vote 0 Issue maybe occured because of the file/script created/downloaded from a windows machine.
down vote Please try converting into linux file format.
dos2unix
./script_name.sh
or
dos2unix
~/.bashrc
Sonu
16310
Your Answer
Sign up or log in
Post as a guest
By posting your answer, you agree to the privacy policy and terms of service.
Not the answer you're looking for? Browse other questions tagged bash shell
cygwin newline or ask your own question.
8/8