LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell script question (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-question-715727/)

icecubeflower 03-31-2009 06:04 AM

shell script question
 
I'm trying to learn shells scripts so I'm going through this tutorial:
http://www.cyberciti.biz/nixcraft/li...ch02sec01.html

Is this a good tutorial or are there better ones?

I typed up his example:
Code:

clear
echo "Hello $USER"
echo "Today is \c ";date
echo "Number of user login : \c" ; who | wc -l
echo "Calendar"
cal
exit 0

But I got this output:
Code:

icecube@inferno:~/shellscripts$ ./ginfo.sh








Hello icecube
Today is \c
Tue Mar 31 05:04:47 CDT 2009
Number of user login : \c
5
Calendar
    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

icecube@inferno:~/shellscripts$

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.

rizwanrafique 03-31-2009 06:25 AM

Use -e switch. ie., echo -e

From echo manpage:
Code:

...
      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
...


pixellany 03-31-2009 06:34 AM

Quote:

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 http://tldp.org ...At the same site is the Advanced Bash Scripting Guide

icecubeflower 03-31-2009 07:17 AM

-e
 
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.

AlucardZero 03-31-2009 07:24 AM

Different versions of echo.


All times are GMT -5. The time now is 04:39 PM.