when I type in a certain command sometimes I'll get output that looks like this.
>
>
>
>
What EXACTLY are the > symbols referring to.
when I type in a certain command sometimes I'll get output that looks like this.
>
>
>
>
What EXACTLY are the > symbols referring to.
Your Case
The ">" symbol in this case means that the terminal wants more input after you've hit the enter key.
In your case, you have a string that hasn't been closed. For instance, if I entered the following command echo "Hello
, and then hit enter, it would give me a ">" until I closed the string.
Example:
If I type in:
eric@Ubuntu: /home/eric$ echo "Hello
>what?
>single quotes won't close it?'
>but double quotes will! "
It would print out the following output:
Hello
what?
single quotes won't close it?'
but double quotes will! "
This allows you to have one string that spans multiple lines, without having to explicitly type in the "\n" newline character.
Extra Information
The fact that a ">" is printed out for this prompt, and not something else is set by the $PS2
environment variable. If you set $PS2
to something else, then that is what you will be prompted with.
Another way to get this prompt to show is by having a backslash ("\") at the end of the line. It basically concatenates two lines together so for example, the following two lines:
eric@Ubuntu: /home/eric$echo "Hello \
>There my friend"
would be processed as eric@Ubuntu: /home/eric$echo "Hello There my friend"
and just output Hello There my friend
.
Both of these methods are used to format you're code in a more readable way. It can be frustrating the first few times you see it as you don't really know what is causing it but when trying to make longer code, or the code's output, readable they will both come in handy.
A pipe it can also be used to append information to a file for instance if you were to type the following in the terminal
echo "Test Line" > test.txt
That will set the contents of test.txt file to "Test Line" with a newline character at the end. If the file doesn't already exist it will be created.
echo "Test Line" >> test.txt
This will add "Test Line" and a newline character to the end of the test.txt file if it exists. If it doesn't exist then file will be created empty, and then this line would be added to it.
>
means redirecting stream to
>>
means redirecting to but at the end
it only applies to stdout
whereas 2>
applies to stderr, obviously using 1>
is the same as >
stdout is the normal program output, stderr is the error output for programs.
So there are two outputs. You can redirect the two outputs using &>
more info here http://www.tldp.org/LDP/abs/html/io-redirection.html