I'm doing a FileCreator script:  #!/bin/bash  echo "Welcome to the file creator! Please type the directory name:" read dirName  mkdir $dirName  #Now I want to change directory to that new $dirName that will be run from Terminal.   My question is now, how to change the path to this new directory dirName that is visible on Terminal. So, at the end, path should be: /home/my_user_name/SCRIPTS/dirName when I run this script ...   Please, just a suggestion? :)
29800
I just want to write a script which changes my directory.  I put the below commands in the file /home/alex/pathABC  #!/bin/sh cd /home/alex/Documents/A/B/C echo HelloWorld   I did   chmod +x pathABC   In the Terminal, while in /home/alex, I ran ./pathABC, but the output is just HelloWorld and the current directory is not changed.  So what is wrong?
119503
I want to create this folder: $HOME/a/b/c/d while $HOME/a has not yet been created! Is it possible with one line in Terminal?
69416
I'm learning how to create shell scripts on UNIX for a college class. The textbook says I should just be able to type the filename in my terminal and it should run, but so far I haven't been able to get that to work. But it works fine when I type in ./myscript. Currently, I am typing the scripts out on my Mac terminal, but I had FreeBSD loaded onto a virtual box and it was doing the same thing to me.  I think maybe I need to change my environment path? I remember I had to do that when I started writing python files.
82471
I've installed a version of Ubuntu Server and although I'm fairly still fresh with Ubuntu, I'm trying to create a bash file to run a program in the background. More importantly, I'm trying to get a file nameto display correct and create it before I start running the program (I like my debug stuff).  However, here is my bash script:    #!/bin/bash  PATH="/var/log/servers/Game/"  FILENAME="startup"  EXT=".log"  DATE=$(date +%d-%m-%Y)  NEWFILE=${PATH}${FILENAME}_${DATE}${EXT}   I have verified that the file does exist in the PATH directory. However, the issue is with the date command. When I run the script bash -x game.sh this is what is displays.   + PATH=/var/log/servers/Game/  + FILENAME=startup  + EXT=.log  ++ date +%d-%m-%Y  game.sh: line 5: date: command not found  + DATE=  + NEWFILE=/var/log/servers/Game/startup_.log  + echo /var/log/servers/Game/startup_.log   I don't understand why it would say the command doesn't work, when I can go to the main console and run date and get a valid response.  Any help is greatly appreciated!
10077
How do I add a directory to the $PATH in Ubuntu and make the changes permanent?
46724
Why when I enter this command the prompt changes to my directory?  PS1='$(pwd)'   I am using single quotes, which means no interpolation , a.k.a echo '$(pwd)' ——→ $(pwd)  Furthermore, say that we clarified why this works... why is it functioning differently from PS1=$(pwd) ? (no quotes at all)  By different I mean that if I use the quotes then the prompt will keep changing to my current directory as I navigate through the terminal. But if I don't use quotes, then the prompt will always remain the directory that I was in when I first entered the command PS1=$(pwd)  why?
75991
What is the proper way to modify environment variables like PATH in OS&nbsp;X?  I've looked on Google a little bit and found three different files to edit:   /etc/paths ~/.profile ~/.tcshrc   I don't even have some of these files, and I'm pretty sure that .tcshrc is wrong, since OS&nbsp;X uses bash now. Where are these variables, especially PATH, defined?  I'm running  (Leopard).
67431
In terminal, how can I define a key to go to the previous directory which I was in when changing directory with the cd command?  For example, I'm in /opt/soft/bin and I cd into /etc/squid3 and I want to get back to the first directory.
103349
I don't get this:  script: WORKDIR/sh/script.sh  [ -e filename ]          \ &amp;&amp; echo filename         \ || [ -e ../filename ]    \ &amp;&amp; echo ../filename      \ || { echo 'ERROR: failed to find "filename"' 1&gt;&amp;2 ; exit -1; }   output:  $ cd WORKDIR/sh $ ./script.sh ../filename  $ cd WORKDIR $ sh/script.sh filename ../filename      # &lt;---- WHY????   My thoughts:  1  [ -e filename ]          \ -&gt; false &amp;&amp;                         -&gt; skip this, it is already false    echo filename         \ -&gt; don't even try || [ -e ../filename ]    \ -&gt; true &amp;&amp; echo ../filename      \ -&gt; true ||                         -&gt; already true, skip the rest    { echo 'ERROR: failed to find "filename"' 1&gt;&amp;2 ; exit -1; }   2  [ -e filename ]          \ -&gt; true &amp;&amp; echo filename         \ -&gt; true ||                         -&gt; already true, skip the rest    [ -e ../filename ]    \ &amp;&amp; echo ../filename      \ || { echo 'ERROR: failed to find "filename"' 1&gt;&amp;2 ; exit -1; }   version:  bash --version GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
9620
I want to run a script to simply change the current working directory:  #!/bin/bash cd web/www/project   But, after I run it, the current pwd remains unchanged! How can I do that?
66951
I have this script:  echo $HOME cd $HOME cd / cd /usr/local/src/   When I run it like this  . script.sh   I get this output:  /home/user : No such file or directory : No such file or directory : No such file or directory   If I run it normally (I added #!/bin/bash before the first line)  sh script.sh   I get this output:  : not found.sh: 2: script.sh /home/user script.sh: 3: Can't cd to /home/user script.sh: 4: Can't cd to / script.sh: 5: Can't cd to /usr/local/src/   The script was run from $HOME directory each time. If I run each command one by one from shell, it executed without problems (invoking cd $HOME from within $HOME simply didn't change directory).  What must I do to make this work?
41626
in .bash_profile I accidentally set the path to:  PATH="~/Tools/apache-maven-3.3.3/bin"   and now the default path is gone. Nothing in Terminal works anymore:  Korays-MacBook-Pro:~ koraytugay$ ls -bash: ls: command not found Korays-MacBook-Pro:~ koraytugay$ mkdir test -bash: mkdir: command not found   I can not see hidden files in Finder so I can not modify .bash_profile from Finder as well.  How can I fix this situation?
119055
i have a directory name with ISO&amp;Emulator having some Important Files. and this directory is in different partition, and partition not showing in my FileManager(Nautilus). so i mount my partition and access it from terminal, but i can't get into directory because of its name.  when i tried to change directory:  cd ISO&amp;Emulator   result:  [1] 1635 bash: Emulator: command not found bash: cd: ISO: No such file or directory [1]+  Exit 1   its taking directory name as a command. any ways for access this directory from terminal?  how to fix this?
121539
Here is my script:  #!/bin/bash  echo "Digite o local em que deseja instalar o IGRAFU(pressione enter para  instalar em  ${HOME}/IGRAFO):" read caminho if test -z $caminho then caminho="${HOME}/IGRAFO" fi echo "O IGRAFU será instalado no diretório: $caminho" mkdir -pv $caminho  mv -v ./* $caminho echo "Pronto!"   At 'read caminho' I may receive from the user a path like ~/somefolder. When the script receives that kind of path both mv and mkdir won't make tilde expansion, so it will try to create a ~/somefolder and not /home/username/somefolder and therefore fail.  How do I ensure that the tilde will be converted into the HOME variable?
38314
touch ~/deleted/$(echo "directory_"$(readlink -f foo)|tr '/' '\') 2&gt; /dev/null   where foo is a directory  It's reading the full pathname of foo and creating it as a file replacing all '/' with '\' and putting a directory_ in front so the directory  /home/test/foo would create a file directory_\home\test\foo  It does exactly what I want except a warning keeps printing tr: warning: an unescaped backslash at end of string is not portable   a. I don't know what that means b. I would like it to not show  I tried to redirect stderr to /dev/null but it doesn't work. How do I suppress it?
21882
In a command prompt window (terminal), how can I get my prompt to be just the current folder?  e.g.  prompt $p $g   gives:  C:\Users\Robin &gt;   But I want it to just show:  Robin &gt;    UPDATE: As @Caius Jard said in the comments, the question identified doesn't duplicate this, as I don't want to simply remove the path, I want to have the current folder name included in the prompt.  e.g.   Program Files &gt;   or   Users &gt;   Hope that clarifies
86504
Hi I would like to run a script from the terminal, is there anyway to do that? For example : if I have a python script I would normally run it with this command :    python script.py   How can I run this script just by typing in the filename of the script in the terminal (even if i'm in another directory) ?  Another answer I found pretty helpful :    You can just create symlink. Create it in /usr/local/bin. All you need is to run command:  sudo ln -s /full/path/to/your/file /usr/local/bin/name_of_new_command   After that you should make your file executable:  chmod +x /full/path/to/your/file   Now you should be able to run name_of_new_command at any time in your terminal.  Note that this is good solution only for home usage of Linux.