LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What does >> do? (https://www.linuxquestions.org/questions/linux-newbie-8/what-does-do-4175532614/)

flyingmouse77 01-31-2015 11:08 AM

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

Head_on_a_Stick 01-31-2015 11:55 AM

It appends the output to the specified file.

By contrast, the ">" operator would replace the content with the output.

flyingmouse77 01-31-2015 12:20 PM

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.

frankbell 01-31-2015 09:09 PM

I'm happy to hear you are enjoying your taste of Linux.

Don't look back.:)

flyingmouse77 02-04-2015 01:42 PM

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

veerain 02-04-2015 01:47 PM

'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.

chrism01 02-05-2015 05:40 AM

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

pan64 02-05-2015 05:46 AM

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)

flyingmouse77 02-05-2015 10:48 AM

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?

suicidaleggroll 02-05-2015 10:52 AM

Quote:

Originally Posted by flyingmouse77 (Post 5312568)
This is definitely fun for me to play with, but when do you actually use Linux in this way?

Multiple times per day, every day.

OSX is very similar to Linux when you're working on the command line, everything just translates straight over.

Head_on_a_Stick 02-05-2015 11:24 AM

Quote:

Originally Posted by flyingmouse77 (Post 5312568)
when do you actually use Linux in this way?

All the time: I have Arch as my main system -- it is a terminal condition...

273 02-05-2015 11:39 AM

Quote:

Originally Posted by flyingmouse77 (Post 5312568)
This is definitely fun for me to play with, but when do you actually use Linux in this way?

One could, I suppose, install and use modern Linux day in day out and only in rare cases have to touch the command line (much as with Windows) but for me, and others I suspect, typing a few commands to update the system and install packages seems more straightforward than messing with a GUI and in the case of my Pi, for example, I don't have a monitor or input devices attached so it is much easier to use SSH to get into it and work on the command line.

flyingmouse77 02-05-2015 02:48 PM

There is something really satisfying about typing in commands and seeing results. :)

chrism01 02-06-2015 03:18 AM

Use that stuff all the time: I work on servers :)

Oh, BTW http://rute.2038bug.com/index.html.gz - Enjoy ;)

flyingmouse77 02-06-2015 09:25 AM

Head on a stick, I see what you did there. :) Clever.


All times are GMT -5. The time now is 11:47 PM.