nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

UNIX / Linux echo command examples

This is a discussion on UNIX / Linux echo command examples within the Getting started tutorials forums, part of the Linux Getting Started category; Here are some examples you may find interesting: Display message welcome on screen Code: echo 'Welcome' Write message File deleted ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Getting started tutorials

Linux answers from nixCraft.


Getting started tutorials So much to read, so little time! If that is your problem, we have solution. Read our FAQ and tutorials to help you cut through the clutter of information overload. Only members of "contributors" group can post new tutorials. Other members can just reply to thread.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 14-03-2007, 01:15 AM
raj's Avatar
raj raj is offline
Senior Member
User
 
Join Date: Jun 2005
Location: Hyderabad
OS: Fedora, Debian Linux
Posts: 307
Thanks: 42
Thanked 8 Times in 8 Posts
Rep Power: 6
raj will become famous soon enough raj will become famous soon enough
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
Reply With Quote
  #2 (permalink)  
Old 15-03-2007, 11:51 PM
B!n@ry's Avatar
Senior Member
User
 
Join Date: Dec 2006
Location: B!n@ry-z0ne
OS: Ojuba 3
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
B!n@ry
Send a message via MSN to B!n@ry
Default

Good work Raj
Keep GOING
__________________
LivE Free 0r DiE
L!nux rul3z aLL
Reply With Quote
  #3 (permalink)  
Old 07-12-2007, 11:20 AM
Junior Member
User
 
Join Date: Dec 2007
OS: Debian
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
virendra is on a distinguished road
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:s o=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;3 1:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz =00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00; 31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;3 5:*.xbm=00;35:*.xpm=00;35:*.png=00;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
Reply With Quote
  #4 (permalink)  
Old 27-04-2009, 12:32 PM
Junior Member
User
 
Join Date: Apr 2009
OS: RHEL5
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
gr8linux is on a distinguished road
Wink

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


try this
#echo $&

what is it?
Reply With Quote
  #5 (permalink)  
Old 27-04-2009, 12:48 PM
Junior Member
User
 
Join Date: Apr 2009
OS: RHEL5
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
gr8linux is on a distinguished road
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)
Reply With Quote
  #6 (permalink)  
Old 03-11-2009, 03:26 PM
Junior Member
User
 
Join Date: Nov 2009
OS: Debian
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
HenriSoren is on a distinguished road
Default

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

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

Reply With Quote
  #7 (permalink)  
Old 14-11-2009, 10:12 PM
Junior Member
User
 
Join Date: Nov 2009
OS: solaris
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
eman samir is on a distinguished road
Default

what exactly does this command do?
echo $?
Reply With Quote
  #8 (permalink)  
Old 15-11-2009, 01:51 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

It will displays the exit status of a command, see
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
The Following User Says Thank You to nixcraft For This Useful Post:
eman samir (15-11-2009)
  #9 (permalink)  
Old 15-11-2009, 02:18 AM
Junior Member
User
 
Join Date: Nov 2009
OS: solaris
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Power: 0
eman samir is on a distinguished road
Default

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

Tags
bash , commands , echo , linux , shell script , unix


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
unix ls command raj Getting started tutorials 2 20-08-2009 03:44 PM
Unix route command view jerry Solaris/OpenSolaris 4 16-04-2009 05:40 PM
unix find out ram usage command charvi Solaris/OpenSolaris 4 10-04-2008 02:22 AM
UNIX and Linux command for DNS chiku Getting started tutorials 1 29-04-2007 04:36 PM
displaying the executed command then echo the status warren Shell scripting 4 29-11-2006 01:56 AM


All times are GMT +5.5. The time now is 08:02 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38