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 04-16-2010, 06:45 AM   #1
sharee
LQ Newbie
 
Registered: Apr 2010
Posts: 10

Rep: Reputation: 0
Whats the difference between Linux and Ubuntu when it comes to bash scripting?


Is one better than the other? Bash scripting in Ubunu is something new for me and I kind of like it. Its similar to programming, in a sense. I have not had the opportunity to perform bash scripting in Linux. It seems like once you learn the commands and how too use them, it becomes easier to bash script.
 
Old 04-16-2010, 06:47 AM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
Ubuntu is Linux distribution. Linux is kernel.
bash is the same for any distro. shell scriptiong can be different for different shells.

Last edited by troop; 04-16-2010 at 06:49 AM.
 
Old 04-16-2010, 07:08 AM   #3
cola
Senior Member
 
Registered: Sep 2007
Location: Dhaka,Bangladesh
Distribution: Debian
Posts: 1,031

Rep: Reputation: 63
Quote:
Originally Posted by sharee View Post
Is one better than the other? Bash scripting in Ubunu is something new for me and I kind of like it. Its similar to programming, in a sense. I have not had the opportunity to perform bash scripting in Linux. It seems like once you learn the commands and how too use them, it becomes easier to bash script.
google bash scripting tutorial.
Bash shell scripting is same on all linux distributions.
 
Old 04-16-2010, 07:59 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by sharee View Post
Is one better than the other? Bash scripting in Ubunu is something new for me and I kind of like it. Its similar to programming, in a sense. I have not had the opportunity to perform bash scripting in Linux. It seems like once you learn the commands and how too use them, it becomes easier to bash script.
Bash has its origins in the "command shell" -- a place outside the kernel (hence "shell") where users could enter commands, have them executed and the results displayed, in the same way as is done at the DOS prompt or the Windows command prompt (in case you are familiar with those). But bash has evolved from UNIX's command shells and UNIX's developers were, er, developers so they made a great tool, something more than a simple place to run commands. Being programmers they naturally gave it program-like capabilities including the genius idea -- a cornerstone of UNIX -- of "piplelining" command together so the output of one could be fed to the input of another and so on thus establishing the UNIX idea of single-purpose tools that could by strung together.

As UNIX/Linux shells have evolved they have gained more programming facilities and are now quite sophisticated in their own right -- functions, recursion, arrays, conditionals, string-manipulation, command output substitution ... and some once external commands have been built in for performance (test and echo are good examples) but bash can use all available commands in a more integrated way than other languages do with their "system" functions.

So yes -- bash scripting is very "similar to programming" and the more "you learn the commands and how too use them", the more you can do with bash scripts.

Beware bash' weaknesses though -- as always it's "horses for courses". Bash is slow at handling large strings and bash has to create a new process to run each external command which is quite slow and expensive in system resources.

EDIT:

Regards ubuntu/Linux, as has already been pointed out, ubuntu is a Linux-based product and bash is more-or-less identical wherever you find it. One difference not mentioned is that not all Linux-based "distros" have the same commands and, even if they do have the same commands, the format of output from those commands may be different. This makes it non-trivial to make "portable" bash scripts that can be run without change on a wide variety of systems.

Last edited by catkin; 04-16-2010 at 08:06 AM.
 
Old 04-16-2010, 08:42 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,546
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Welcome to LQ!

'bash' is very useful to any user that really wants control of their system or perform maintenance on a UNIX or GNU/Linux system.

Quote:
excerpt from 'man bash';
NAME
bash - GNU Bourne-Again SHell
SYNOPSIS
bash [options] [file]
COPYRIGHT
Bash is Copyright (C) 1989-2004 by the Free Software Foundation, Inc.
DESCRIPTION
Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh).

Bash is intended to be a conformant implementation of the IEEE POSIX Shell and Tools specification (IEEE Working Group 1003.2).
You should look at a sample setup for .bashrc & .bash_profile for a user. This is a good way to control and streamline things for a user;

Code:
sample .bash_profile;

~$ cat .bash_profile

# .bash_profile
#08-30-06 12:21
#
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
Code:
sample .bashrc;
:~$ cat .bashrc

#.bashrc
#08-30-06 12:20 

# Add bin to path

export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

#08-29-06 11:40

if [ `id -un` = root ]; then
   PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
 else
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi

#
# Add color
eval `dircolors -b`

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
   trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#   trap 0 rm -f ~$LOGNAME/.bash_history
The .bashrc is very useful! If you discern the above files you will be able to understand the strength and usefulness of bash.

Just a few useful links;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Bash Reference Manual <<<<<<< Great & Useful
Advanced Bash-Scripting Guide <<<<<<<< Very helpful
Linux Newbie Admin Guide
LinuxSelfHelp
Getting Started with Linux

The above links and others can be found at 'Slackware-Links' . More than just SlackwareŽ links!
 
Old 04-16-2010, 08:49 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Quote:
Originally Posted by sharee View Post
Is one better than the other? Bash scripting in Ubunu is something new for me and I kind of like it. Its similar to programming, in a sense. I have not had the opportunity to perform bash scripting in Linux. It seems like once you learn the commands and how too use them, it becomes easier to bash script.
ummm, Ubuntu is a Linux distro. Just like Fedora, Red Hat, Debian, arch, etc.
 
  


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
Whats the difference between ksh and bash? dev_d Linux - Newbie 11 02-26-2010 05:17 PM
Whats the difference between Linux and Unix? runnerpaul Linux - Newbie 3 04-15-2008 06:22 PM
shell versus bash, whats the difference? mayaabboud Linux - Newbie 5 12-21-2007 07:21 AM
Solaris and redhat difference in bash scripting champak Programming 9 12-04-2007 05:39 PM
Whats the difference Linux Console and BASH Shell glenn69 Linux - Newbie 2 08-31-2003 04:19 PM


All times are GMT -5. The time now is 10:41 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration