LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-31-2015, 11:08 AM   #1
flyingmouse77
LQ Newbie
 
Registered: Jan 2015
Posts: 7

Rep: Reputation: Disabled
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
 
Old 01-31-2015, 11:55 AM   #2
Head_on_a_Stick
Senior Member
 
Registered: Dec 2014
Location: London, England
Distribution: Debian stable (and OpenBSD-current)
Posts: 1,187

Rep: Reputation: 285Reputation: 285Reputation: 285
It appends the output to the specified file.

By contrast, the ">" operator would replace the content with the output.
 
1 members found this post helpful.
Old 01-31-2015, 12:20 PM   #3
flyingmouse77
LQ Newbie
 
Registered: Jan 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thumbs up 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.
 
Old 01-31-2015, 09:09 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
I'm happy to hear you are enjoying your taste of Linux.

Don't look back.
 
1 members found this post helpful.
Old 02-04-2015, 01:42 PM   #5
flyingmouse77
LQ Newbie
 
Registered: Jan 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-04-2015, 01:47 PM   #6
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
'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.
 
1 members found this post helpful.
Old 02-05-2015, 05:40 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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
 
1 members found this post helpful.
Old 02-05-2015, 05:46 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
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)
 
1 members found this post helpful.
Old 02-05-2015, 10:48 AM   #9
flyingmouse77
LQ Newbie
 
Registered: Jan 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
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?
 
Old 02-05-2015, 10:52 AM   #10
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by flyingmouse77 View Post
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.
 
1 members found this post helpful.
Old 02-05-2015, 11:24 AM   #11
Head_on_a_Stick
Senior Member
 
Registered: Dec 2014
Location: London, England
Distribution: Debian stable (and OpenBSD-current)
Posts: 1,187

Rep: Reputation: 285Reputation: 285Reputation: 285
Quote:
Originally Posted by flyingmouse77 View Post
when do you actually use Linux in this way?
All the time: I have Arch as my main system -- it is a terminal condition...
 
2 members found this post helpful.
Old 02-05-2015, 11:39 AM   #12
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
Quote:
Originally Posted by flyingmouse77 View Post
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.
 
1 members found this post helpful.
Old 02-05-2015, 02:48 PM   #13
flyingmouse77
LQ Newbie
 
Registered: Jan 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
There is something really satisfying about typing in commands and seeing results.
 
Old 02-06-2015, 03:18 AM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Use that stuff all the time: I work on servers

Oh, BTW http://rute.2038bug.com/index.html.gz - Enjoy
 
1 members found this post helpful.
Old 02-06-2015, 09:25 AM   #15
flyingmouse77
LQ Newbie
 
Registered: Jan 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Head on a stick, I see what you did there. Clever.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration