Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Echo command  (Read 3451 times)

0 Members and 1 Guest are viewing this topic.

Suhi100

    Topic Starter


    Newbie

    • Experience: Experienced
    • OS: Unknown
    Echo command
    « on: February 11, 2015, 11:31:40 AM »
    Hi,

    I have a question about Echo. I have read about what it is and what it is used for ,but did not really help me to understand what the following line mean. Cananyona help please?

    echo .> D:\Projects\logs\WinScpFtp_log.txt


    What I cant find on the web is what  these characters mean .>

    Does this mean that it puts in the file WinScpFtp_log.txt a dot?

    Thanks


    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: Echo command
    « Reply #1 on: February 11, 2015, 12:48:51 PM »
    Yes but it also overwrites that file if it already exists.  If you need to append to the log file then you would use two >
    You are physically echoing a period and redirecting the output to the log file.

    Salmon Trout

    • Guest
    Re: Echo command
    « Reply #2 on: February 11, 2015, 12:58:29 PM »
    This:

    (with a space between echo and the dot!)

    echo . > path\filename

    echoes a dot and a newline (cr + lf) to the file, creating the file if it does not exist, overwriting the file completely if it already exists.

    Note however:

    This:

    (no space between the echo and the dot!)

    echo. > path\filename

    echoes a blank new line to the file.



    Redirection operators:

    > create new file if it does not exist, over-write file if it exists.

    >> create new file if it does not exist, append to file (add to end of file if it exists.


    Salmon Trout

    • Guest
    Re: Echo command
    « Reply #3 on: February 11, 2015, 01:01:52 PM »

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Echo command
    « Reply #4 on: February 11, 2015, 02:36:42 PM »
    Also, because DOS batch was not intended as a learning language for those new to computer programming. If you look for information about computer languages, batch is seldom, if ever, listed as suitable for newcomers.
    Instead you might see:
    Quote
    Assembly (a relatively simple dialect)
    C is a Procedural language,
    Java / C# / Eiffel / C++: Something Object-Oriented 
    LISP and Prolog: Teaches students a new way to think,
    SQL and XML: Introduces new ways to think about data and how to retrieve it and manage
    To be sure,  there are excellent tutorials for  batch. As was mentioned by Salmon Trout above. But you have to read them.

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: Echo command
    « Reply #5 on: February 11, 2015, 03:40:25 PM »
    Well said Salmon Trout.
    I visit SS64 and Rob Vanderwoude's site as well.
    http://www.robvanderwoude.com/redirection.php

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Echo command
    « Reply #6 on: February 12, 2015, 07:45:42 AM »
    This:

    echo . > path\filename

    echoes a dot and a newline (cr + lf) to the file

    Just idly commenting here that your examples also add spaces.

    Salmon Trout

    • Guest
    Re: Echo command
    « Reply #7 on: February 12, 2015, 09:24:12 AM »
    Just idly commenting here that your examples also add spaces.

    You know, I was on the bus coming back from work, and I thought "I put spaces before the redirections".

    Correction:

    This:

    (with a space between echo and the dot!)

    echo .> path\filename

    echoes a dot and a newline (cr + lf) to the file, creating the file if it does not exist, overwriting the file completely if it already exists.

    Note however:

    This:

    (no space between the echo and the dot!)

    echo.> path\filename

    echoes a blank new line to the file.



    Redirection operators:

    > create new file if it does not exist, over-write file if it exists.

    >> create new file if it does not exist, append to file (add to end of file if it exists.



    [/quote]