LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-14-2003, 03:20 PM   #1
kubicon
Member
 
Registered: Aug 2003
Location: Limbo
Posts: 54

Rep: Reputation: 15
Bash, Emacs


question 1
with emacs, if you open a file that has a .sh extension it defaults to bash scripting mode, which is nice. Now, Is there a way to show the line numbers along the sides.

question 2
I'm learning bash scripting. When I try string comparison, bash gives me an error. Eg:

Code:
name="foo"
name2="bar"

if[ "$name" = "foo" ]
then
echo "yes"
fi

# or


if[$name = "foo"]
then
echo "yes"
fi

# or

if ["$name" = "$name2"]
then
echo "yes"
fi
All of the above give me errors. What's going on
 
Old 09-14-2003, 03:36 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
Spaces are important!!! Among other syntax related issues.

Code:
name="foo"
name2="bar"
#if[ "$name" = "foo" ]
if [ "$name" = "foo" ]
then
echo "yes"
fi
# or
#if[$name = "foo"]
if [ $name = "foo" ]
then
echo "yes"
fi
# or
#if ["$name" = "$name2"]
if [ "$name" = "$name2" ]
then
echo "yes"
fi
 
Old 09-14-2003, 03:49 PM   #3
XT8088
LQ Newbie
 
Registered: Sep 2003
Distribution: RH9
Posts: 9

Rep: Reputation: 0
Reply - Question 2

If I run the following in BASH:

#!/bin/bash
#
#
name="foo"
name2="bar"
#
if [ $name = foo ]
then
echo "yes"
fi

# or

if [ $name = "foo" ]
then
echo "yes"
fi

# or

if [ $name = $name2 ]
then
echo "yes"
fi


file is "test"
Output as follows:

[root@localhost cmd_wm]# bash test
yes
yes
[root@localhost cmd_wm]#
 
Old 09-14-2003, 04:27 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389
And that is correct.

1) $name = foo => foo = foo => true => echo yes
2) $name = "foo" => foo = foo => true => echo yes
3) $name = $name2 => foo = bar => false => continue

About you emacs question:

C-e C-l

Which I found with google.......... (I don't use emacs).

Last edited by druuna; 09-14-2003 at 04:28 PM.
 
Old 09-14-2003, 09:11 PM   #5
kubicon
Member
 
Registered: Aug 2003
Location: Limbo
Posts: 54

Original Poster
Rep: Reputation: 15
thanks for the answer with the 2nd question.
In the first question, I mean displaying line numbers along the sides of each line automatically, eg:
1) something
2) something else
3) third line here

I don't know if such thing is possible, it just seem to me like it would be. I tried searching in google and found nothing. Oh well, it someone knows about this then let me know, otherwise is no big deal.

BTW: C-e C-l does nothing
thanks anyways, though
 
Old 09-14-2003, 09:26 PM   #6
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
The file setnu.el available at

http://www.wonderworks.com/

apparently does the line-number thing. Personally I'm happy with

M-x line-number-mode

which toggles display of the current line number in the status bar.
 
  


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
'Screen' ignores bash/emacs prefs! Why? stutterbug Red Hat 0 01-20-2005 06:57 AM
edb (emacs database) won't open file - emacs 20 & 21 tip184 Linux - Software 0 04-03-2004 07:31 AM
Text Mode Editor: What Choices? BASH, VI, EMACS? LinxAI Linux - Newbie 12 03-28-2004 11:17 PM
bash: emacs: command not found appel Linux - Software 1 08-05-2003 09:18 AM
bash logout profile rc cs emacs sreenrc ravenarts Linux - Newbie 2 05-15-2002 08:01 PM


All times are GMT -5. The time now is 01:53 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration