LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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, 12:08 PM   #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, 12:55 PM   #2
Head_on_a_Stick
Senior Member
 
Registered: Dec 2014
Location: London, England
Distribution: Arch & Debian
Posts: 1,183

Rep: Reputation: 283Reputation: 283Reputation: 283
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, 01: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, 10:09 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mint, OpenBSD
Posts: 11,333
Blog Entries: 12

Rep: Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729Reputation: 2729
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, 02: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, 02: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, 06:40 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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, 06:46 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
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, 11: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, 11:52 AM   #10
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
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, 12:24 PM   #11
Head_on_a_Stick
Senior Member
 
Registered: Dec 2014
Location: London, England
Distribution: Arch & Debian
Posts: 1,183

Rep: Reputation: 283Reputation: 283Reputation: 283
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, 12:39 PM   #12
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 5,993

Rep: Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611Reputation: 1611
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, 03: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, 04:18 AM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
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, 10: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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




All times are GMT -5. The time now is 12:12 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration