pavement

Echo

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
 
m (bsdwiki boldface conventions in terminal sessions)
 
(2 intermediate revisions by 2 users not shown)
Line 5: Line 5:
  
 
The simplest way to explain it is to see it in action:
 
The simplest way to explain it is to see it in action:
  samizdata# echo "hello!"
+
  samizdata# '''echo "hello!"'''
 
  hello!
 
  hello!
It can also be used to add input to a file:
+
It can also be used to create and/or add input to a file:
  samizdata# echo "This is a test file" > /root/testfile
+
  samizdata# '''echo "This will overwrite whatever is in the file" > /root/testfile'''
  samizdata# more /root/testfile
+
  samizdata# '''more /root/testfile'''
  This is a test file
+
  This will overwrite whatever is in the file
  samizdata#
+
  samizdata# '''echo "This will append to whatever is in the file" >> /root/testfile'''
 +
samizdata# '''more /root/testfile'''
 +
This will overwrite whatever is in the file
 +
This will append to whatever is in the file
 +
 
 +
See [[redirection]] for more on using > and >> and other operands to move data to and from [[standard input]], [[standard output]], files, and programs.
 +
[[Category:System Commands]]

Latest revision as of 13:51, 24 December 2004

echo repeats whatever has been given to it. From the manpage:

    The echo utility writes any specified operands, separated by single blank
    (` ') characters and followed by a newline (`\n') character, to the stan-
    dard output.

The simplest way to explain it is to see it in action:

samizdata# echo "hello!"
hello!

It can also be used to create and/or add input to a file:

samizdata# echo "This will overwrite whatever is in the file" > /root/testfile
samizdata# more /root/testfile
This will overwrite whatever is in the file
samizdata# echo "This will append to whatever is in the file" >> /root/testfile
samizdata# more /root/testfile
This will overwrite whatever is in the file
This will append to whatever is in the file

See redirection for more on using > and >> and other operands to move data to and from standard input, standard output, files, and programs.

Personal tools