LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 05-17-2009, 02:04 PM   #1
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Rep: Reputation: 16
quick newb question


I know that >> appends to the bottom of a file...
but what does << do?
I've searched google, and found that google ignores special characters, and there're no entries in the man file or help files, that i could find...
 
Old 05-17-2009, 02:11 PM   #2
forrestt
Senior Member
 
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
It sends the file on the right of the << as the input for the command.

HTH

Forrest
 
Old 05-17-2009, 02:26 PM   #3
cynicalpsycho
Member
 
Registered: Mar 2009
Location: America
Distribution: Debian/Arch
Posts: 134

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by forrestt View Post
It sends the file on the right of the << as the input for the command.

HTH

Forrest
could you elaborate with an example?
 
Old 05-17-2009, 02:29 PM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,036

Rep: Reputation: 96
There are three standard file handles that you need to know about

stdin 0
stdout 1
stderr 2

Commands take input from stdin, send normal output to stdout and send error messages to stderr

< file sends the contents of file into stdin to be used by command xyz
<< file reads lines of input from the keyboard, until the message "file" is given.

> file or 1> file redirects the normal output to file (replacing the previous content if the file exists)
>> file or 1>> file redirects normal output to file (appending to the end of the file)

2> file redirects the error messages to file (replacing the previous content if the file exists)
2>> file redirects the error messages to file (appending to the end of the file)

2>&1 redirects the error messages to the address for stdout

Last edited by Disillusionist; 05-17-2009 at 02:39 PM. Reason: Correction
 
Old 05-17-2009, 02:45 PM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,036

Rep: Reputation: 96
Quote:
Originally Posted by cynicalpsycho View Post
could you elaborate with an example?
Code:
cat << EOF
This is an example of the use of <<

The input is read until you reach a line that just contains EOF.

It could be anything, but typically EOF is used ;)
EOF
 
Old 05-17-2009, 03:49 PM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
The example from Disillusionist is a so-called "here document". If you want to fed a command with a simple string you can use a "here string" using the triple input redirection:
Code:
grep example <<< "A simple example"
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Networkl newb needs quick tutorial (sticky?) twoHats Linux - Server 0 08-25-2006 12:49 PM
Newb question sicness Slackware 4 11-09-2005 04:40 AM
3 quick newb laptop questions DeadPenguin SUSE / openSUSE 4 04-12-2005 09:50 AM
Quick NewB Ques on Kernel Updating dot hog Linux - Newbie 2 10-18-2003 04:50 PM
Newb ? - Create Quick Launch (Gnome) ThomasR Linux - Newbie 2 05-07-2002 04:53 PM


All times are GMT -5. The time now is 07:01 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