It is actually 2 commands. You need to cd to the source-dir if you run the exact same find command as it searches in . (which means the current directory). If you don't cd to the directory first then you must use an absolute, or relative path to the source-dir, e.g.
Do I have to enter in all of that code into the command line is one of the things I'd like to know.
Or is it just fine to skip the first line and do the last two lines.
find /home/username/source-dir # absolute path from / (root dir)
find source-dir # relative (source-dir in current dir)
find ../source-dir # relative (source-dir in parent dir)
Yeah, they probably should have the $ prompt in there. It would make it clearer. However, when I entered that find command the prompt changed to a > character, meaning that it was waiting for more input. I did get the same error when I tried using quotes though, so I think that is where you are going wrong. Just type it in exactly as written, but changing the source-dir and dest-dir as needed.
And I thought if you were running multiple commands at once you were required to have the " ; " character in there or did I misinterpret something ? I would assume they were different lines but I would expect something like " ~$ " in front of them. And I thought " | " was used in one command and " \ " was used in case you were going to use a second line for one long command.
The | is called a pipe. It's used to send the output of one program to the input of another program. So, you're running find and pruning the results, then piping the output of that to the cpio program. Here's a simple example of piping (cd on its own takes you to your home directory, and grep is a program for searching for patterns):
Once you know about pipes you realize that it can't be three commands and the second line has to run into the third one. I think that whenever you end a line with | bash will sit there waiting for you to tell it where to pipe the output to.
ls -la | grep Do
The \ is called the 'escape character'. In bash some characters have special meanings. To stop bash interpreting these characters they have to be 'escaped'.
It's used to split a long command into multiple lines because the newline character is special. Bash interprets it as 'this-is-the-end-of-the-command', so using \ escapes the newline.
I came up with this example:
I ended up with just ~/dest-dir/Two/two.txt, so the entire One directory was skipped, as was the file wasn't in One, but ended with ~
mkdir source-dir dest-dir
mkdir One Two
touch One/one.txt One/one.txt~
touch Two/two.txt Two/two.txt~
find . -name One -prune -o \( \! -name *~ -print0 \) | cpio -pmd0 ~/dest-dir