Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirection???

Status
Not open for further replies.

TheBigBasicQ

Programmer
Dec 20, 2001
107
IN
Whats the difference between the '>' and '>>' operator and '<' and '<<'???

For example:

$ ls -l > myfile.txt

and

$ ls -l >> myfile.txt

Nobody is perfect =(
.
.
.
.
I am nobody =D
 
&quot;>&quot; overwrites an existing file or starts a new one if it does not exist.

&quot;>>&quot; appends to an existing file or starts a new one if it does not exist.

Surfinbox.com Business Internet Services - National Dialup, DSL, T-1 and more.
 
Code:
<
means to read input from the file.
Code:
<<
starts a here-document.

//Daniel
 
whats a here-document?

Nobody is perfect =(
.
.
.
.
I am nobody =D
 
It allows you to send input to a program from the command line, like this
Code:
cat > /etc/resolv.conf <<EOF
search domain.tld
nameserver 1.2.3.4
EOF
which I use in an initscript to recreate my
Code:
/etc/resolv.conf
after dhclient has done it's job.

//Daniel
 
hmm...ok so let me get this straight. < is used to redirect input to commands and << is redirect input to programs?

Nobody is perfect =(
.
.
.
.
I am nobody =D
 
Code:
<
is used to redirect input from a file.
Code:
<<
is used to redirect input from command line.

//Daniel
 
Thanks those links were quite useful

Nobody is perfect =(
.
.
.
.
I am nobody =D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top