0% found this document useful (0 votes)
5 views2 pages

Understanding Korn Shell Basics

The document provides an overview of Unix and Korn shell, highlighting that almost everything is treated as a file and discussing shell scripting nuances. It details Korn shell configuration files, metacharacters, quoting mechanisms, and special file permissions like SUID, SGID, and the sticky bit. Additionally, it covers important signals in scripting, common shell commands, and utilities for file type identification and output manipulation.

Uploaded by

Bogus Malus
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Understanding Korn Shell Basics

The document provides an overview of Unix and Korn shell, highlighting that almost everything is treated as a file and discussing shell scripting nuances. It details Korn shell configuration files, metacharacters, quoting mechanisms, and special file permissions like SUID, SGID, and the sticky bit. Additionally, it covers important signals in scripting, common shell commands, and utilities for file type identification and output manipulation.

Uploaded by

Bogus Malus
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

• in Unix almost everything is a file – there are devices (can be files)

• shell scripting is not programing, but close enough (too many exceptions, buggy)

Korn shell config files


Invoking Korn Shell sopsurces
1. /etc/enviromnet – sourced by all AIX processes (the basic of the shell)
2. /etc/profile – sourced by login shells (set by admins to be valid for all users)
3. .profile – user specific settings
4. ENV file – a resource file listed in the ENV

Metacharacters
Characters with special meaning.
Can be turned off by shell options.
* - match any number of characters
? - match any single character
[abc] – match a single character from the bracketed list
[!abc] – match any single character except those listed
[a-z] – inclusive range for a list
These above can be combined within the brackets. Define ranges first, then specific
characters, eg.: [a-f0-4G-Lxyz] – will find a-f and 0-4 and G-L and xyz also.
[[:upper:]] – range list of all upper case letters
[[:lower:]] – all lower case letters
[[:digits:]] – digits
[[:space:]] – spacing characters: tab, space, etc.
*(pattern|pattern...) - zero or more occurrences

Quoting
Stops normal shell metacharacter processing, including metacharacter expansion:
“” - removes metacharacter meaning of any special characters within the “”, except 3 special cases ($ `
(backquote) \)
'' - removes metacharacter meaning of any special characters within the ''
\ - removes metacharacter meaning of any special character directly after the \

• SUID bit set – the file will run under the name of the owner, regardless of who runs it actually.
• SGID bit set – is assigned to a directory. When set, it overrides the primary group of the user
creating a file inside the directory, and sets the group ownership of the file to that of the
directory's owner group
• Sticky bit – it is for directories, where everybody can write but not everybody should be able to
remove stuff. Users can create and modify stuff inside, but delete only their own files.
Signals
kill -l lists signals
Important signals in scripting are:
1 – SIGHUP reinitialize, reread its configuration without stopping ans starting
2 – SIGINT interrupt, same as Ctrl+c
3 – SIGQUIT quit, same as Ctrl+d
9;15;17
18 – TSTP suspend process to background (same as Ctrl+Z)
19 – CONT continue if stopped

$ file <filename> - tells what type the file is

$ exec <shell/program name> - terminates current shell/program and starts another


shell/program

$ . <script name> - starts a script

$ ksh <script name> - run a script in a new Korn Shell even if there is no execution right on it

$ ps – see which shell I am in

[[ 1234 = +([0-9]) ]] - tests whether '1234' is a number (whether it consists of characters 0-


9, nothing else)

set -o vi - enables line recall and editing

$ <some output> | awk '{print $<N>}' - fetches only the Nth column of the output (i.e.
it finds the delimiter by itself (hopefully, but usually very effectively))

$ diff <file1> <file2> - compares the 2 files and writes the difference on the screen

You might also like