Tech Kaizen

passion + usefulness = success .. change is the only constant in life

Search this Blog:

Unix Shell Scripts

A Unix shell, also called "the command line", provides the traditional user interface for the Unix operating system and for Unix-like systems. Users direct the operation of the computer by entering command input as text for a shell to execute. Within the Microsoft Windows suite of operating systems the analogous program is command.com, or cmd.exe for Windows NT-based operating systems.

The most generic sense of the term shell means any program that users use to type commands. Since in the Unix operating system users can select which shell they want to use (which program should execute when they login), many shells have been developed. It is called a "shell" because it hides the details of the underlying operating system behind the shell's interface (in contrast with the "kernel", which refers to the lowest-level, or 'inner-most' component of an operating system). Similarly, graphical user interfaces for Unix, such as GNOME, KDE, and Xfce can be called visual shells or graphical shells. By itself, the term shell is usually associated with the command line. In Unix, any program can be the user's shell. Users who want to use a different syntax for typing commands can specify a different program as their shell.

The term shell also refers to a particular program, such as the Bourne shell, sh. The Bourne shell was the shell used in early versions of Unix and became a de facto standard; every Unix-like system has at least one shell compatible with the Bourne shell. The Bourne shell program is located in the Unix file hierarchy at /bin/sh. On some systems, such as BSD, /bin/sh is a Bourne shell or equivalent, but on other systems such as Linux, /bin/sh is likely to be a link to a compatible, but more feature-rich shell(like Bash shell). POSIX specifies its standard shell as a strict subset of the Korn shell.

You can use any one of these shells if they are available on your system. And you can switch between the different shells once you have found out if they are available -
.
Different Shells

1. Bourne shell (sh)
2. C shell (csh)
3. TC shell (tcsh)
4. Korn shell (ksh)
5. Bourne Again SHell (bash)

Bourne shell (sh)
This is the original Unix shell written by Steve Bourne of Bell Labs. It is available on all UNIX systems. This shell does not have the interactive facilites provided by modern shells such as the C shell and

Korn shell
You are advised to to use another shell which has these features.
The Bourne shell does provide an easy to use language with which you can write shell scripts.

C shell (csh)
This shell was written at the University of California, Berkley. It provides a C-like language with which to write shell scripts- hence its name.

TC shell (tcsh)
This shell is available in the public domain. It provides all the features of the C shell together with emacs style editing of the command line.

Korn shell (ksh)
This shell was written by David Korn of Bell labs. It is now provided as the standard shell on Unix systems. It provides all the features of the C and TC shells together with a shell programming language similar to that of the original Bourne shell. It is the most efficient shell. Consider using this as your standard interactive shell.

Bourne Again Shell (bash)
This is a public domain shell written by the Free Software Foundation under their GNU initiative. Ultimately it is intended to be a full implementation of the IEEE Posix Shell and Tools specification. This shell is widely used within the academic commnity. bash provides all the interactive features of the C shell (csh) and the Korn shell (ksh). Its programming language is compatible with the Bourne shell (sh). If you use the Bourne shell (sh) for shell programming consider using bash as your complete shell environment.

Summary of shell facilities
--------------------------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
________________________________________________________
* not the default setting for this shell

Details:

The sh utility is a sophisticated shell (command interpreter) that offers, depending on the options chosen, compatibility with the Korn, Bourne-Again, and POSIX shells available on many UNIX systems. You can use it as a replacement for the standard Windows command interpreter (cmd.exe)

When invoked with the sh name, sh is primarily a POSIX.2 compatible shell with some selected Korn and Bourne-Again shell behavior.

resh is a restricted version of that shell and is equivalent to sh -r. For more information on the restricted shell, see the description of the -r option. Regardless of how it is launched, this reference page uses resh to refer to the restricted shell.

ksh is a version of the shell that uses, by default, standard Korn behavior when it may conflict with bash or MKS KornShell behavior. ksh is equivalent to running sh with the -K or -o korn options. Regardless of how it is launched, this reference page uses ksh to refer to the shell operating in KornShell mode.

Bash(Bourne-Again Shell) is the shell, or command language interpreter, that will appear in the GNU operating system. Bash is an sh-compatible shell that incorporates useful features from the Korn shell (ksh) and C shell (csh).

Accessing AWK variables in SHELL Script: Using “eval”

eval `echo $* awk -F: '{printf("a=%s; b=%s; c=%s\n", $1, $2, $3)}'`
print $a
print $b
print $c

Accessing SHELL variables in AWK Script
1.Protect the shell variables from awk by enclosing them with "'" (i.e. double quote - single quote - double quote).


awk '{print "'"$VAR1"'", "'"$VAR2"'"}' input_file

2. Use the -v switch to assign the shell variables to awk variables. This works with nawk, but not with all flavours of awk. On my system (Solaris 2.6) -v cannot be used with /usr/bin/awk but will work with /usr/xpg4/bin/awk.

nawk -v v1=$VAR1 -v v2=$VAR2 '{print v1, v2}' input_file


Links:
Advanced Bash-Scripting Guide -
http://www.faqs.org/docs/abs/HTML/index.htmlhttp://tldp.org/LDP/abs/html/

Unix Shell Scripting -
http://cfaj.freeshell.org/shell/

Bash Shell Guide -
www.gnu.org/software/bash/manual/

Unix Shells -
http://www.ussg.iu.edu/usail/external/recommended/diffshell.html

Effective AWK programming -
http://www.gnu.org/manual/gawk/gawk.pdf

Manipulating Strings : Shell Scripts -
http://www.faqs.org/docs/abs/HTML/string-manipulation.html

Linux Shell Scripting Tutorial v1.05r3 - A Beginner's handbook -
http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/lsst/

Awk, Sed & grep -
http://www.securitydocs.com/pdf/3489.PDF

Awk & Sed -
http://unix.ittoolbox.com/topics/t.asp?t=429&p=429&h1=429#

Accessing AWK variables from Shell -
http://www.unix.com/shell-programming-scripting/32384-access-awk-variables-outside-scope.html

Accessing Shell Variables from AWK -
http://www.tek-tips.com/faqs.cfm?fid=1281

Labels: UNIX OPERATING SYSTEM
Newer Post Older Post Home

The Verge - YOUTUBE

Loading...

Google - YOUTUBE

Loading...

Microsoft - YOUTUBE

Loading...

MIT OpenCourseWare - YOUTUBE

Loading...

FREE CODE CAMP - YOUTUBE

Loading...

NEET CODE - YOUTUBE

Loading...

GAURAV SEN INTERVIEWS - YOUTUBE

Loading...

Y Combinator Discussions

Loading...

SUCCESS IN TECH INTERVIEWS - YOUTUBE

Loading...

IGotAnOffer: Engineering YOUTUBE

Loading...

Tanay Pratap YOUTUBE

Loading...

Ashish Pratap Singh YOUTUBE

Loading...

Questpond YOUTUBE

Loading...

Kantan Coding YOUTUBE

Loading...

CYBER SECURITY - YOUTUBE

Loading...

CYBER SECURITY FUNDAMENTALS PROF MESSER - YOUTUBE

Loading...

DEEPLEARNING AI - YOUTUBE

Loading...

STANFORD UNIVERSITY - YOUTUBE

Loading...

NPTEL IISC BANGALORE - YOUTUBE

Loading...

NPTEL IIT MADRAS - YOUTUBE

Loading...

NPTEL HYDERABAD - YOUTUBE

Loading...

MIT News

Loading...

MIT News - Artificial intelligence

Loading...

The Berkeley Artificial Intelligence Research Blog

Loading...

Microsoft Research

Loading...

MachineLearningMastery.com

Loading...

Harward Business Review(HBR)

Loading...

Wharton Magazine

Loading...
My photo
Krishna Kishore Koney
View my complete profile
" It is not the strongest of the species that survives nor the most intelligent that survives, It is the one that is the most adaptable to change "

View krishna kishore koney's profile on LinkedIn

Monthly Blog Archives

  • ►  2025 (2)
    • ►  May (1)
    • ►  April (1)
  • ►  2024 (18)
    • ►  December (1)
    • ►  October (2)
    • ►  September (5)
    • ►  August (10)
  • ►  2022 (2)
    • ►  December (2)
  • ►  2021 (2)
    • ►  April (2)
  • ►  2020 (17)
    • ►  November (1)
    • ►  September (7)
    • ►  August (1)
    • ►  June (8)
  • ►  2019 (18)
    • ►  December (1)
    • ►  November (2)
    • ►  September (3)
    • ►  May (8)
    • ►  February (1)
    • ►  January (3)
  • ►  2018 (3)
    • ►  November (1)
    • ►  October (1)
    • ►  January (1)
  • ►  2017 (2)
    • ►  November (1)
    • ►  March (1)
  • ►  2016 (5)
    • ►  December (1)
    • ►  April (3)
    • ►  February (1)
  • ►  2015 (15)
    • ►  December (1)
    • ►  October (1)
    • ►  August (2)
    • ►  July (4)
    • ►  June (2)
    • ►  May (3)
    • ►  January (2)
  • ►  2014 (13)
    • ►  December (1)
    • ►  November (2)
    • ►  October (4)
    • ►  August (5)
    • ►  January (1)
  • ►  2013 (5)
    • ►  September (2)
    • ►  May (1)
    • ►  February (1)
    • ►  January (1)
  • ►  2012 (19)
    • ►  November (1)
    • ►  October (2)
    • ►  September (1)
    • ►  July (1)
    • ►  June (6)
    • ►  May (1)
    • ►  April (2)
    • ►  February (3)
    • ►  January (2)
  • ►  2011 (20)
    • ►  December (5)
    • ►  August (2)
    • ►  June (6)
    • ►  May (4)
    • ►  April (2)
    • ►  January (1)
  • ►  2010 (41)
    • ►  December (2)
    • ►  November (1)
    • ►  September (5)
    • ►  August (2)
    • ►  July (1)
    • ►  June (1)
    • ►  May (8)
    • ►  April (2)
    • ►  March (3)
    • ►  February (5)
    • ►  January (11)
  • ►  2009 (113)
    • ►  December (2)
    • ►  November (5)
    • ►  October (11)
    • ►  September (1)
    • ►  August (14)
    • ►  July (5)
    • ►  June (10)
    • ►  May (4)
    • ►  April (7)
    • ►  March (11)
    • ►  February (15)
    • ►  January (28)
  • ▼  2008 (61)
    • ►  December (7)
    • ►  September (6)
    • ►  August (1)
    • ►  July (17)
    • ▼  June (6)
      • STL (Standard Template Library) Part1
      • Source Code Reverse Engineering using Doxygen,Grap...
      • Source Code Analysis Tools
      • The 25 Most Innovative Products of the Year by PC ...
      • Unix Shell Scripts
      • .Net Programming Introduction
    • ►  May (24)
  • ►  2006 (7)
    • ►  October (7)

Blog Archives Categories

  • .NET DEVELOPMENT (38)
  • 5G (5)
  • AI (Artificial Intelligence) (9)
  • AI/ML (4)
  • ANDROID DEVELOPMENT (7)
  • BIG DATA ANALYTICS (6)
  • C PROGRAMMING (7)
  • C++ PROGRAMMING (24)
  • CAREER MANAGEMENT (6)
  • CHROME DEVELOPMENT (2)
  • CLOUD COMPUTING (45)
  • CODE REVIEWS (3)
  • CYBERSECURITY (12)
  • DATA SCIENCE (4)
  • DATABASE (14)
  • DESIGN PATTERNS (9)
  • DEVICE DRIVERS (5)
  • DOMAIN KNOWLEDGE (14)
  • EDGE COMPUTING (4)
  • EMBEDDED SYSTEMS (9)
  • ENTERPRISE ARCHITECTURE (10)
  • IMAGE PROCESSING (3)
  • INTERNET OF THINGS (2)
  • J2EE PROGRAMMING (10)
  • KERNEL DEVELOPMENT (6)
  • KUBERNETES (19)
  • LATEST TECHNOLOGY (18)
  • LINUX (9)
  • MAC OPERATING SYSTEM (2)
  • MOBILE APPLICATION DEVELOPMENT (14)
  • PORTING (4)
  • PYTHON PROGRAMMING (6)
  • RESEARCH AND DEVELOPMENT (1)
  • SCRIPTING LANGUAGES (8)
  • SERVICE ORIENTED ARCHITECTURE (SOA) (10)
  • SOFTWARE DESIGN (13)
  • SOFTWARE QUALITY (5)
  • SOFTWARE SECURITY (23)
  • SYSTEM and NETWORK ADMINISTRATION (3)
  • SYSTEM PROGRAMMING (4)
  • TECHNICAL MISCELLANEOUS (31)
  • TECHNOLOGY INTEGRATION (5)
  • TEST AUTOMATION (5)
  • UNIX OPERATING SYSTEM (4)
  • VC++ PROGRAMMING (44)
  • VIRTUALIZATION (8)
  • WEB PROGRAMMING (8)
  • WINDOWS OPERATING SYSTEM (13)
  • WIRELESS DEVELOPMENT (5)
  • XML (3)

Popular Posts

  • Observer Pattern - Push vs Pull Model
  • AI Agent vs AI Workflow
  • Microservices Architecture ..
  • SSCLI(Shared Source Common Language Infrastructure)

My Other Blogs

  • Career Management: Invest in Yourself
  • Color your Career
  • Attitude is everything(in Telugu language)
WINNING vs LOSING

Hanging on, persevering, WINNING
Letting go, giving up easily, LOSING

Accepting responsibility for your actions, WINNING
Always having an excuse for your actions, LOSING

Taking the initiative, WINNING
Waiting to be told what to do, LOSING

Knowing what you want and setting goals to achieve it, WINNING
Wishing for things, but taking no action, LOSING

Seeing the big picture, and setting your goals accordingly, WINNING
Seeing only where you are today, LOSING

Being determined, unwilling to give up WINNING
Gives up easily, LOSING

Having focus, staying on track, WINNING
Allowing minor distractions to side track them, LOSING

Having a positive attitude, WINNING
having a "poor me" attitude, LOSING

Adopt a WINNING attitude!

Total Pageviews

who am i

My photo
Krishna Kishore Koney

Blogging is about ideas, self-discovery, and growth. This is a small effort to grow outside my comfort zone.

Most important , A Special Thanks to my parents(Sri Ramachandra Rao & Srimathi Nagamani), my wife(Roja), my lovely daughter (Hansini) and son (Harshil) for their inspiration and continuous support in developing this Blog.

... "Things will never be the same again. An old dream is dead and a new one is being born, as a flower that pushes through the solid earth. A new vision is coming into being and a greater consciousness is being unfolded" ... from Jiddu Krishnamurti's Teachings.

Now on disclaimer :
1. Please note that my blog posts reflect my perception of the subject matter and do not reflect the perception of my Employer.

2. Most of the times the content of the blog post is aggregated from Internet articles and other blogs which inspired me. Due respect is given by mentioning the referenced URLs below each post.

Have a great time

My LinkedIn Profile
View my complete profile

Failure is not falling down, it is not getting up again. Success is the ability to go from failure to failure without losing your enthusiasm.

Where there's a Will, there's a Way. Keep on doing what fear you, that is the quickest and surest way to to conquer it.

Vision is the art of seeing what is invisible to others. For success, attitude is equally as important as ability.

Favourite RSS Syndications ...

Google Developers Blog

Loading...

Blogs@Google

Loading...

Berklee Blogs » Technology

Loading...

Martin Fowler's Bliki

Loading...

TED Blog

Loading...

TEDTalks (video)

Loading...

Psychology Today Blogs

Loading...

Aryaka Insights

Loading...

The Pragmatic Engineer

Loading...

Stanford Online

Loading...

MIT Corporate Relations

Loading...

AI at Wharton

Loading...

OpenAI

Loading...

AI Workshop

Loading...

Hugging Face - Blog

Loading...

BYTE BYTE GO - YOUTBUE

Loading...

Google Cloud Tech

Loading...

3Blue1Brown

Loading...

Bloomberg Originals

Loading...

Dwarkesh Patel Youtube Channel

Loading...

Reid Hoffman

Loading...

Aswath Damodaran

Loading...