Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-31-2009, 05:04 AM   #1
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Rep: Reputation: 34
shell script question

I'm trying to learn shells scripts so I'm going through this tutorial:

Is this a good tutorial or are there better ones?

I typed up his example:
echo "Hello $USER"
echo "Today is \c ";date
echo "Number of user login : \c" ; who | wc -l
echo "Calendar"
exit 0
But I got this output:
icecube@inferno:~/shellscripts$ ./

Hello icecube
Today is \c
Tue Mar 31 05:04:47 CDT 2009
Number of user login : \c
     March 2009
Su Mo Tu We Th Fr Sa
 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

Why does it say "Today is \c"? Isn't it supposed to substitute the output of the "date" command in there? I am using bash shell.
Old 03-31-2009, 05:25 AM   #2
Registered: Jul 2006
Distribution: Debian, Ubuntu, openSUSE, CentOS
Posts: 147

Rep: Reputation: 19
Use -e switch. ie., echo -e

From echo manpage:
       If -e is in effect, the following sequences are recognized:

       \0NNN  the character whose ASCII code is NNN (octal)

       \\     backslash

       \a     alert (BEL)

       \b     backspace

       \c     suppress trailing newline
Old 03-31-2009, 05:34 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
Is this a good tutorial or are there better ones?
Can't say which is better, but my favorite is the Bash Guide for Beginners---free at ...At the same site is the Advanced Bash Scripting Guide
Old 03-31-2009, 06:17 AM   #4
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 313

Original Poster
Rep: Reputation: 34

Hey I tried echo -e, that works, thank you.

I wonder why his example doesn't have -e in it?

I like this tutorial but I think he is from India or something, his English isn't perfect.
Old 03-31-2009, 06:24 AM   #5
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Different versions of echo.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script question radiodee1 Linux - Newbie 3 03-25-2007 12:38 PM
Shell Script Question swinchen Programming 1 08-20-2004 02:09 PM
Shell script question. siaful Linux - Newbie 1 04-29-2004 05:01 PM
Help me!!!!!shell script question!!!!!! yulitao Programming 2 03-23-2004 03:40 PM
Shell script question rytrom Linux - Newbie 4 01-28-2004 07:20 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:14 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration