Introduction to UNIX and shell cripting

29 315 0
Introduction to UNIX and shell cripting

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Confidential to Trianz Inc. • 1 Confidential to Trianz Inc. • 2 • Introduction to Unix and its architecture • Learn to use basic Unix commands • Learn to use vi editor • Learn to write shell scripts • Learn to register and run shell scripts from oracle applications Confidential to Trianz Inc. What is UNIX ? UNIX is an operating system co-created by AT&T Bell Labs researchers Dennis Ritchie and Ken Thompson in the late 1960s. Unix is a multitasking, multiuser, programming environment. • 3 Confidential to Trianz Inc. • 4 Confidential to Trianz Inc. Kernel – is the single large program which resides in the memory which is the operating system. It manages File system, Memory, I/O and Processes. Shell – is a command interpreter which provides the user interface for the UNIX operating system. • 5 Confidential to Trianz Inc.  HP-UX - HP UNIX developed by HP  SunOS and Solaris – Developed by Sun Microsystems  AIX – Developed by IBM  SCO Unix – Developed by SCO  Linux - Free Source code  BSD – Berkley Software Design • 6 Confidential to Trianz Inc.  Bourne shell (sh)  C shell (csh)  TC shell (tcsh)  Korn shell (ksh)  Bourne Again SHell (bash) • 7 Confidential to Trianz Inc. Bourne C TC Korn BASH Command history No Yes Yes Yes Yes Command alias No Yes Yes Yes Yes Shell scripts Yes Yes Yes Yes Yes Filename completion No Yes* Yes Yes* Yes Command line editing No No Yes Yes* Yes Job control No Yes Yes Yes Yes • 8 * not the default setting for this shell Confidential to Trianz Inc. There are three types of file access supported by UNIX.  r – read, view the contents of a file or a directory  w – write, edit file/directory contents  x – execute, run executable file • 9 Confidential to Trianz Inc. • 10 - rwx r-x r 1 user1 oracle 858 Feb 22 22:28 file1.txt type owner group size Modification date/time File name User permissions Group permissions Other Permissions links For example: Suppose you type in ls -l and the result is [...]... a shell script should start with a line: #!/bin/ksh Example shell script #!/bin/bash echo “Hello $USER” echo “Today is “ `date` echo “You are in directory $PWD” exit 0 Confidential to Trianz Inc •20 Ex: ls –lrt, myshell.sh oracle $1 to $9 – will give the arguments 1 to 9 To get remaining we need to use shift command $@ - will give the complete list of all the arguments to that shell Confidential to. .. The shell script can have either of the 2 extensions .prog or sh prog : 1 Create a soft link to the shell without extension to $FND_TOP/bin/fndcpesr Ex: ln -s $FND_TOP/bin/fndcpesr $FND_TOP/bin/TEST 2 Grant execute permission to the both the files (.prog and the file without extension) Ex: chmod +x TEST.prog TEST sh : No need to create a soft link Confidential to Trianz Inc •27 Differences b/w prog and. ..ls - List directory contents cd - Change the current directory cp - Copy files and directories mv - Move (rename) files mkdir - Make a directory rm - Remove files or directories (Use with Caution) rmdir – Delete a directory (Use with Caution) echo – Display a line of text Confidential to Trianz Inc •11 cat – Concatenate files and print on the std output date – Print the system date and time head –... bytes, words, and lines in files ln - Make links between files Confidential to Trianz Inc •13 alias/unalias - Shorthand for a command or commands sort - Sort lines of text files exit – Exit the current shell with status shift – Shift positional parameters env – Display the environment variables logout - Exit a login shell Confidential to Trianz Inc •14 There are 2 types of variables in Unix Environment... types of variables in Unix Environment variables  Shell variables  As per conventions environment variables will be in uppercase and Shell variables will be in lowercase Example : APPL_TOP=/srv/115102/inst/visappl pathseg=/home/oracle/bin today=`date` export – to export the variable to the environment Confidential to Trianz Inc •15 Redirection operators: Output redirection : >, |, >> Input redirection... is greater than $x” fi Confidential to Trianz Inc •22 For loops for name in w1 w2 do command-list done Example: for X in red green blue do echo $X done Confidential to Trianz Inc •23 While Loops while command-list1 do command-list2 done Example: x=0 while [ $x -le 20 ] do echo $x x=`expr $x + 1` done Confidential to Trianz Inc •24 $? - returns 0 if the last command is executed successfully, else non... Example: cat test1 test2 > test3 cat test2 >> test1 ls –l | grep new sort < test.txt > sortedtest.txt Confidential to Trianz Inc •16 vi – Visual text editor vi - to open the any text file in vi editor Two modes of vi Command mode – Esc key  Insert mode – a or i  Confidential to Trianz Inc •17 a - enter append mode i - enter insert mode h - move cursor left j - move cursor down k - move... last command PID run in bg (using &) $$ - returns the current shell PID Confidential to Trianz Inc •25 sqlplus -s /@ @/ Example 1: sqlplus -s $UID/$PWD@$CONSTR@$EXECDIR/sql/oa_com_monitor_cmrun Example 2 : st_date=`sqlplus -s $UID/$PWD@$CONSTR . Confidential to Trianz Inc. • 1 Confidential to Trianz Inc. • 2 • Introduction to Unix and its architecture • Learn to use basic Unix commands • Learn to use vi editor • Learn to write shell scripts • Learn. I/O and Processes. Shell – is a command interpreter which provides the user interface for the UNIX operating system. • 5 Confidential to Trianz Inc.  HP-UX - HP UNIX developed by HP  SunOS and. -l and the result is Confidential to Trianz Inc. ls - List directory contents cd - Change the current directory cp - Copy files and directories mv - Move (rename) files mkdir - Make a directory rm

Ngày đăng: 24/10/2014, 10:53

Từ khóa liên quan

Mục lục

  • PowerPoint Presentation

  • Course Coverage

  • Introduction to Unix

  • Unix Architecture

  • Unix Architecture

  • UNIX Flavors

  • Types of Shells

  • Summary of shell facilities

  • File Permissions

  • Slide 10

  • UNIX Commands

  • Slide 12

  • Slide 13

  • Slide 14

  • Unix Variables

  • I/O Redirection

  • vi Text Editor – King of all editors

  • Some Simple VI Commands

  • Slide 19

  • Shell scripting

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan