Results 1 to 9 of 9

Thread: UNIX / Linux echo command examples

  1. #1
    Senior Member raj's Avatar
    Join Date
    Jun 2005
    Location
    Hyderabad
    Posts
    566
    Thanks
    57
    Thanked 41 Times in 38 Posts
    Rep Power
    14

    Default UNIX / Linux echo command examples

    Here are some examples you may find interesting:

    Display message welcome on screen
    Code:
    echo 'Welcome'
    Write message File deleted to a file called /tmp/log.txt
    Code:
    echo 'File has been deleted' > /tmp/log.txt
    Append message File deleted to a file called /tmp/log.txt
    Code:
    echo 'File has been deleted' >> /tmp/log.txt
    Append message and command output on screen
    Code:
    echo "Today's date is $(date)"
    Append message and command output to a file
    Code:
    echo "Today's date is $(date)" > /tmp/date.txt
    More help - just type command
    Code:
    man echo
    Raj
    Linux rulz.
    I have never turned back in my life ; I shall not do so today.. haha

  2. #2
    Senior Member B!n@ry's Avatar
    Join Date
    Dec 2006
    Location
    B!n@ry-z0ne
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Good work Raj
    Keep GOING
    LivE Free 0r DiE
    L!nux rul3z aLL

  3. #3
    Junior Member
    Join Date
    Dec 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    echo is a very powerful tool


    #env
    this command will show
    HOSTNAME=viren.com
    TERM=xterm
    SHELL=/bin/bash
    HISTSIZE=1000
    KDE_NO_IPV6=1
    SSH_CLIENT=10.16.5.139 1885 22
    SSH_TTY=/dev/pts/0
    USER=root
    LS_COLORS=no=00:fi=00:di=00;34:ln=00;36i=40;33:so=00;35:bd=40;33;01:cd=40;33;01r=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32: *.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*. sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj =00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00; 31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.t z=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif =00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=0 0;35:*.tif=00;35:
    KDEDIR=/usr
    MAIL=/var/spool/mail/root
    PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
    INPUTRC=/etc/inputrc
    PWD=/root
    LANG=en_US.UTF-8
    KDE_IS_PRELINKED=1
    SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
    SHLVL=1
    HOME=/root
    LOGNAME=root
    SSH_CONNECTION=172.16.5.139 1885 172.16.5.235 22
    LESSOPEN=|/usr/bin/lesspipe.sh %s
    G_BROKEN_FILENAMES=1
    _=/bin/env



    and then understand what echo can do

    like

    #echo $PATH
    #echo $HOSTNAME
    #echo $HISTSIZE

  4. #4
    Junior Member
    Join Date
    Apr 2009
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Wink

    what is himBH?
    when i typed
    # echo $-
    the o/p displayed himBH.


    try this
    #echo $&

    what is it?

  5. #5
    Junior Member
    Join Date
    Apr 2009
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Red face echo

    i hv read abt the q parameter used with echo, as:

    echo -e "\033[2q"

    it turns on the num lock key's LED, but it wont effect the num keypad. i wanna know is it only for the LEDs or it actually works? (same for 0q, 1q, 3q)

  6. #6
    Junior Member
    Join Date
    Nov 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Here's a little trick i often use, Brace Expansion:

    Code:
    $ echo {one,two,red,blue}fish
    onefish twofish redfish bluefish


  7. #7
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    what exactly does this command do?
    echo $?

  8. #8
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,513
    Thanks
    17
    Thanked 807 Times in 511 Posts
    Rep Power
    10
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  9. The Following User Says Thank You to nixcraft For This Useful Post:

    eman samir (15th November 2009)

  10. #9
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by nixcraft View Post
    i owe you great thanks,as i was going to go mad because of unix

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. unix ls command
    By raj in forum Getting started tutorials
    Replies: 5
    Last Post: 24th April 2013, 10:27 PM
  2. Unix route command view
    By jerry in forum Solaris/OpenSolaris
    Replies: 4
    Last Post: 16th April 2009, 05:40 PM
  3. unix find out ram usage command
    By charvi in forum Solaris/OpenSolaris
    Replies: 4
    Last Post: 10th April 2008, 02:22 AM
  4. UNIX and Linux command for DNS
    By chiku in forum Getting started tutorials
    Replies: 1
    Last Post: 29th April 2007, 04:36 PM
  5. displaying the executed command then echo the status
    By warren in forum Shell scripting
    Replies: 4
    Last Post: 29th November 2006, 01:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •