LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-23-2011, 04:08 AM   #16
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled

Quote:
Originally Posted by kenny53067 View Post
In this script, the only command line is the very first line, all the rest are script? is this correct?
journal is your script and you've entered "cat journal" at the command line (or command prompt). So yes, you're correct.
 
1 members found this post helpful.
Old 07-23-2011, 04:16 AM   #17
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
It is used as a command at the command prompt. The command prompt is displayed by the shell (usually bash) in a terminal. Which desktop are you using? Could be Gnome, KDE, Unity ... Details of how to start a terminal depend on the desktop.
All I know is that I have installed a VMware player and the word Fedora is at the top. I go to applications/system tools/terminal and a terminal is open.
 
Old 07-23-2011, 04:19 AM   #18
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 kenny53067 View Post
In this script, the only command line is the very first line, all the rest are script? is this correct?
A script is, generally, a file containing commands. For a bash script, anything following a # is a comment (unless the # is buried inside something like a string).

Thus, in the journal script, there are 3 comments:
Code:
#!/bin/bash
# journal: add journal entries to the file
# $HOME/journal-file
The last two are simply comments to help the programmer. The first is special; it's a shebang. A shebang allows you to run a script as if it were a command. A #!/bin/bash shebang says "start /bin/bash and give it this file as input to execute". The file is a script and it contains bash commands, the same commands as you could type in at a command prompt.
 
1 members found this post helpful.
Old 07-23-2011, 04:23 AM   #19
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 kenny53067 View Post
All I know is that I have installed a VMware player and the word Fedora is at the top. I go to applications/system tools/terminal and a terminal is open.
Good; so you have a terminal and hopefully the terminal is displaying a command prompt. The prompt is configurable so could be anything (what's yours?) but conventionally ends with a $. You can type a command and press Enter and the command will be run (executed). For example the ls command lists files in your current directory and the date command tells you the time and date. The chmod (change mode) command can be used to set the permissions on files and directories.
 
1 members found this post helpful.
Old 07-23-2011, 04:27 AM   #20
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
A script is, generally, a file containing commands. For a bash script, anything following a # is a comment (unless the # is buried inside something like a string).

Thus, in the journal script, there are 3 comments:
Code:
#!/bin/bash
# journal: add journal entries to the file
# $HOME/journal-file
The last two are simply comments to help the programmer. The first is special; it's a shebang. A shebang allows you to run a script as if it were a command. A #!/bin/bash shebang says "start /bin/bash and give it this file as input to execute". The file is a script and it contains bash commands, the same commands as you could type in at a command prompt.
Do all my command lines start with a $
 
Old 07-23-2011, 04:29 AM   #21
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
Good; so you have a terminal and hopefully the terminal is displaying a command prompt. The prompt is configurable so could be anything (what's yours?) but conventionally ends with a $. You can type a command and press Enter and the command will be run (executed). For example the ls command lists files in your current directory and the date command tells you the time and date. The chmod (change mode) command can be used to set the permissions on files and directories.
This is what is displayed [kenny@localhost ~]$

Is this what is called a command prompt?
 
Old 07-23-2011, 04:32 AM   #22
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 kenny53067 View Post
Do all my command lines start with a $
No. The command prompt ends with a $ but it is not part of the command. The shell uses $ as a "dereference operator" meaning if you have a variable called foo, $foo means "the value of variable foo". It is possible to create commands that begin with $ but they would be inconvenient to use because of the shell's use of $
 
Old 07-23-2011, 04:34 AM   #23
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 kenny53067 View Post
This is what is displayed [kenny@localhost ~]$

Is this what is called a command prompt?
That is a command prompt

The ~ part of it shows that your current directory is your home directory. If you cd (change directory) to something else it will change. You could try cd /tmp to see what I mean. Plain cd will get you back to your home directory.

Last edited by catkin; 07-23-2011 at 04:34 AM. Reason: Spelling: Plaid to Plain
 
Old 07-23-2011, 04:51 AM   #24
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
That is a command prompt

The ~ part of it shows that your current directory is your home directory. If you cd (change directory) to something else it will change. You could try cd /tmp to see what I mean. Plain cd will get you back to your home directory.
I tried cd/tmp and got this, bash: cd/tmp: no such file or directory
 
Old 07-23-2011, 04:53 AM   #25
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 kenny53067 View Post
I tried cd/tmp and got this, bash: cd/tmp: no such file or directory
cd is the command and /tmp is an "argument" to the command. Commands and their arguments must be separated by spaces (or tabs).

---------- Post added 23rd Jul 2011 at 14:24 ----------

Have fun; I am going for lunch.
 
1 members found this post helpful.
Old 07-23-2011, 04:56 AM   #26
kenny53067
Member
 
Registered: Jul 2011
Location: Rio Grande City, Texas
Posts: 54

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by catkin View Post
cd is the command and /tmp is an "argument" to the command. Commands and their arguments must be separated by spaces (or tabs).

---------- Post added 23rd Jul 2011 at 14:24 ----------

Have fun; I am going for lunch.
That worked, Thanks

I'm going to bed, it's 4am here!!
 
Old 07-23-2011, 05:02 AM   #27
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You should probably have a read of this. It is titled "Advanced", but starts with basics of shell scripting.
 
Old 07-24-2011, 08:05 PM   #28
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
In addition to post #27, here are a couple of good links
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html

As Nylex implied, his link is like the sequel to the beginner's guide, but it's not super difficult, just more techniques.
All 3 links are worth bookmarking imho.
 
  


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
PHP script wont execute linuxfreak3 Programming 2 07-07-2010 03:02 PM
How to execute a ssh script on Linux server from Windows through a bat script? wanna13e Programming 13 10-23-2009 03:41 AM
Pico wont run unless I execute it via dot slash, WHY? JustinK101 Linux - Software 2 01-10-2007 08:18 PM
YaST wont execute from icon on the applications menu! stephen_lewitowski SUSE / openSUSE 1 06-29-2006 11:58 AM
why wont this file and another one execute? Frustin Linux - Software 2 06-06-2002 07:47 AM


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