What does >> do?
Hello all,
I've been given a basic Linux assignment in my Computer Concepts class, and I *think* I managed to enter all the commands and get the results expected. :) But I also have to define terms relating to Linux, and I've found everything except >>. I actually used it in my exercise: Type echo “enter_your_name_here” >> test2, but I'm not sure exactly what it did. Can anyone help? Thanks! flyingmouse77 |
It appends the output to the specified file.
By contrast, the ">" operator would replace the content with the output. |
Thank You!
I really appreciate your help! I was surprised to find I actually enjoyed playing around with Linux. :) It was fun to use the commands and see things happen.
|
I'm happy to hear you are enjoying your taste of Linux.
Don't look back.:) |
Now it's >
Hello all,
Head on a Stick told me that > would replace the content with the output. In this Linux exercise, our first step is to create a file named test1, using the touch command. The following step is to type echo "This is a test" > test1. Typing cat test1 shows This is a test. So am I understanding this correctly when I think test1 has been replaced with This is a test? When I try to duplicate the effect, I'm not successful. :( flyingmouse77 |
'touch test1' creates a empty file named test1 if only no such file exists.
So better do 'echo abc > test1' Then check with 'cat test1' Then again put some text with 'echo def > test1' Then check with 'cat test1' So you would see abc replaced with def. |
Basically, when talking about files, take care to be explicit about whether you are talking about the file as a whole, the filename, or the file content... ;)
'cat' is short for catalogue (way back when) - basically types out the content of the file to stdout touch is used to create a file (also to alter timestamps) echo 'string' > file puts 'string' into file REPLACING current content ( '>>' appends to current content) NB: this means that '>file' empties the file :) HTH |
see the complete description for example here: http://www.tldp.org/LDP/abs/html/io-redirection.html
(or you can check the redirections in the man page of bash too) |
Thanks for all your replies!
I got a perfect score on my Linux lab, and actually learned a lot! The professor suggested working with DOS as well as Apple (ugh) to see similarities and differences. Apparently learning directory hierarchies was one of the goals here. This is definitely fun for me to play with, but when do you actually use Linux in this way? |
Quote:
OSX is very similar to Linux when you're working on the command line, everything just translates straight over. |
Quote:
|
Quote:
|
There is something really satisfying about typing in commands and seeing results. :)
|
Use that stuff all the time: I work on servers :)
Oh, BTW http://rute.2038bug.com/index.html.gz - Enjoy ;) |
Head on a stick, I see what you did there. :) Clever.
|
All times are GMT -5. The time now is 11:47 PM. |