I am new to Ubuntu and I have recently learned how to open a folder in the terminal for example
cd Desktop
A problem occurred when I tried to open a folder called "ovn 1.2.1". When running
cd ovn 1.2.1
in the terminal, the terminal answers with "could not find any folder called ovn".
If by map you mean directory such as Desktop, on your terminal, escape the spaces, like this:
$ cd ovn\ 1.2.1
Or, enclose in quotes, ' or " quotes are fine:
$ cd 'ovn 1.2.1'
You can use quotes ("s) to shield the directory name from the shell:
mureinik#computer ~ $ mkdir "ovn 1.2.1"
mureinik#computer ~ $ cd "ovn 1.2.1"
mureinik#computer ~/ovn 1.2.1 $
Try this:
cd ovn\ 1.2.1
you can also start typing cd ovn and then hit Tab key for autocomplete
Try ovn\ 1.2...
\ is treated as space in terminal.
Related
I'm doing the react tutorial and I'm having trouble with step 3.
I put the lines in the tutorial
cd my-app
rm -f src/*
into my node.js command prompt and got "'rm' is not recognized as an internal or external command, operable program or batch file."
How can I work around this problem?
This doesn't go in your node.js prompt. It's an OS command. If you are using linux, OSX, or ubuntu-on-windows, you should type it in your terminal.
If you are using windows, you can use rmdir \S \Q src
If you are in linux or Mac OS you should do
cd my-app && rm -f src/*
This will remove all the files in src and will keep the folders its files.
If you want to remove everything from src then use:
cd my-app && rm -rf src/*
On my Desktop I have created a folder called "Files", I would like to know how to access that folder through a shell script
When in Linux file system using bash you can navigate to the home directory in many ways:
After you reach the home directory everything is easy from there including reaching Desktop.
The ~ or $HOME reference:
In Linux based systems the keyword ~ or $HOME refers to the home directory of the computer.
For example say you are currently at /bin, to navigate to home if you know your username you would do :
$ cd /home/yourusername
#The directory is now switched to :
$ pwd #This command stands for print working directory
'/home/yourusername'
Now you can do it alternatively by:
(Again assuming you are in /bin)
$ cd $HOME
$ pwd
'/home/yourusername'
#Alternatively
$ cd /bin
$ cd ~
$ pwd
'/home/yourusername'
These shortcuts let you go to home without writing much and are even recommended.
Now for your problem you can easily navigate to your folder by:
cd ~/Desktop/Files/
I launch bash scripts normally with the ./ command.
But if I try to launch the script with the full path I get an error
No such file or directory
I am so confused, I made a search to be sure to get the right path.
$ pwd
/home/pi/server/
$ ls
start_scan
$ sudo chmod 777 start_scan
$ sudo find / -xdev -name start_scan
/home/pi/server/start_scan
$ ./home/pi/server/start_scan
-bash: ./home/pi/server/start_scan: No such file or directory
Do you have any idea what could the problem be? I am using a macbook to use SSH and connect to a Rapsberry Pi under Raspbian and execute the script there.
./ is no command, but a path that means the current working directory.
Your line is almost correct, just remove the dot at the beginning:
/home/pi/server/start_scan
When you type any path starting with a dot, the shell expands it to the current working directory, effectively searching in
/home/pi/server/home/pi/server/start_scan
which is obviously wrong.
command line shell
echo %PIG_HOME%
C:\cygwin\usr\lib\pig
cygwin
echo $PIG_HOME
C:\cygwin\usr\lib\pig
echo $( cygpath -u "$PIG_HOME" )
/usr/lib/pig
cd $( cygpath -u "$PIG_HOME" )
-bash: cd: /usr/lib/pig: No such file or directory
Question: why is cygpath not converting it to /cygdrive/c/cygwin/usr/lib/pig?
UPDATE:
The path to the pig folder is correct.
command line shell
C:\Users\john.doe> cd %PIG_HOME%
C:\cygwin\usr\lib\pig>
cygwin
john.doe#COMPUTER ~
$ cd /cygdrive/c/cygwin/usr/lib/pig/
john.doe#COMPUTER /cygdrive/c/cygwin/usr/lib/pig
$
With Cygwin,
C:\cygwin\lib\pig = /usr/lib/pig
and
C:\cygwin\usr\lib\pig = /cygdrive/c/cygwin/usr/lib/pig
This setup is by design.
The C:\cygwin\usr\lib folder is not created by any packages and should not be created by you either.
Type mount in your terminal window.
My c:\cygwin\bin and c:\cygwin\lib\ are mounted at /usr/bin and /usr/lib respectively. I suspect that your c:\cygwin\usr\lib is mounted at /usr/lib.
Therefore, the "unix" path to c:\cygwin\usr\lib\pig would be /usr/lib/pig.
Did you try option "-m, --mixed : like --windows, but with regular slashes (C:/WINNT)"
$ cd /cygdrive/c/cygwin64/home
$ cygpath -m $(pwd)
C:/cygwin64/home
In a bash shell script today I noticed the below command at the end of the script. I know what is cd but I am unaware of the significance of a dash after it.
cd -
What does this mean? Google naively truncates the - so I am unable to find its answer.
If a single dash is specified as the argument, it will be replaced by the value of OLDPWD.
The OLDPWD is set by cd command and it is the previous working directory.
cd - returns to the directory you were previously.
For instance:
marcelo#marcelo:~$ cd /opt
marcelo#marcelo:/opt$ cd /usr/bin
marcelo#marcelo:/usr/bin$ cd -
/opt
marcelo#marcelo:/opt$
I was in /opt, changed to /usr/bin, and then went back to /opt with cd -
cd - brings you back to the last directory.
$ cd ~/Desktop
$ pwd
/Users/daknok/Desktop
$ cd /
$ pwd
/
$ cd -
$ pwd
/Users/daknok/Desktop
cd - returns to the previous directory you were in.
Say I'm in /usr/ and I type cd /var/local/someplace/else
Then I use cd - I'll return to /usr
From the manual
An argument of - is equivalent to $OLDPWD. If a non-empty directory
name from CDPATH is used, or if - is the first argument, and the
directory change is successful, the absolute pathname of the new
working directory is written to the standard output. The return
value is true if the directory was successfully changed; false
otherwise
Therefore the - is equivalent to the $OLDPWD, which holds the last directory which the shell was in, and is set by the previous cd invocation.
From the man found here : http://ss64.com/bash/cd.html
Quickly get back
$ cd -
cd - bring you back to the last directory you were.
e.g.
cd ~/Documents
cd ~
cd /
Now you are in '/', and if you run 'cd -' you will be in '~'. BTW, run 'cd -' once again, you will return to '/' but not '~/Documents'
“ Current Directory “ Is what the bash cd terminal command means. It means “ keep me in this directory “