LinuxQuestions.org
Review your favorite Linux distribution.
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 12-15-2010, 10:22 AM   #1
Madison00
LQ Newbie
 
Registered: Oct 2010
Posts: 10

Rep: Reputation: 0
learning korn shell


I am learning ksh shell and have question, below is the command and I am not clear exactly it mean:

#!/bin/ksh
ScriptDir=`dirname $0`


1. does it mean they want to set ScriptDir variable to dirname?
2. $0: is it standard input?

3. I have been reading a lot of book and able to understand each seperate command, my problem is I have a hard time to put all of the command together. any recommendations?

Thanks
 
Old 12-15-2010, 10:36 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,
Quote:
Originally Posted by Madison00 View Post
I am learning ksh shell and have question, below is the command and I am not clear exactly it mean:

#!/bin/ksh
ScriptDir=`dirname $0`


1. does it mean they want to set ScriptDir variable to dirname?
dirname $0 is between backticks, which means that it (dirname $0) is executed and the content is put into the SCriptDir variable.

Quote:
2. $0: is it standard input?
$0 holds the name of the script itself. $1, $2, $N are the "input" you give when starting a script.
I.e: myscript.ksh foo bar -> $0 will be myscript.ksh, $1 would be foo and $2 bar.

Quote:
3. I have been reading a lot of book and able to understand each seperate command, my problem is I have a hard time to put all of the command together. any recommendations?
KSH has some dialects and it depends a bit on which you use. I like Learning the Korn Shell by O'Reilly (ISBN 1-56592-054-6) it focusses on ksh88.

Hope this helps.
 
Old 12-15-2010, 10:46 AM   #3
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
Quote:
Originally Posted by Madison00 View Post
I am learning ksh shell and have question, below is the command and I am not clear exactly it mean:

#!/bin/ksh
ScriptDir=`dirname $0`


1. does it mean they want to set ScriptDir variable to dirname?
2. $0: is it standard input?

3. I have been reading a lot of book and able to understand each seperate command, my problem is I have a hard time to put all of the command together. any recommendations?

Thanks
1. dirname strips the non-directory suffix from the file name. i.e. /home/your_login/filename >> /home/your_login.
2. $0 is the first element on the command line, $1 is the next one, $2 is after that, ... up to $9 and then things change.

Code:
$ > man dirname
will explain the dirname command. You can do 'man whatever' to read the manpage on a command.

HTH,
 
  


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
korn shell and spellcheck kofucii Linux - Newbie 1 08-20-2009 07:41 PM
need help with korn shell on fedora 9 dsharp63 Linux - Newbie 4 05-08-2009 01:49 PM
Globbing using Korn Shell metallica1973 Programming 1 12-05-2007 05:56 PM
Korn Shell equivalent bassplayer69 Linux - General 1 08-02-2007 02:15 PM
korn shell tutorial/course kapilcool Linux - Certification 2 11-13-2006 10:18 PM


All times are GMT -5. The time now is 08:10 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