LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 03-31-2009, 06:04 AM   #1
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 304

Rep: Reputation: 33
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.
 
Old 03-31-2009, 06:25 AM   #2
rizwanrafique
Member
 
Registered: Jul 2006
Distribution: Debian, Ubuntu, openSUSE, CentOS
Posts: 147

Rep: Reputation: 19
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
...
 
Old 03-31-2009, 06:34 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729Reputation: 729
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
 
Old 03-31-2009, 07:17 AM   #4
icecubeflower
Member
 
Registered: Mar 2008
Location: USA
Distribution: Slackware 13.1
Posts: 304

Original Poster
Rep: Reputation: 33
-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.
 
Old 03-31-2009, 07:24 AM   #5
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,652

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


Reply


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 01:38 PM
Shell Script Question swinchen Programming 1 08-20-2004 03:09 PM
Shell script question. siaful Linux - Newbie 1 04-29-2004 06:01 PM
Help me!!!!!shell script question!!!!!! yulitao Programming 2 03-23-2004 04:40 PM
Shell script question rytrom Linux - Newbie 4 01-28-2004 08:20 AM


All times are GMT -5. The time now is 09:59 AM.

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