Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

C Shell Scripting

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ What is C shell? C shell is a Unix shell created in 1979 by Bill Joy soon after the Bourne shell was released in 1977. Although the latter went on to be the standard shell for Unix, C shell is still popular in BSD distributions. C shell's scripting syntax is modeled after the C language in some aspects. Small programs can be created by writing scripts using the C shell syntax. The Bourne shell is also an option to create Unix scripts but if you are reading this book you probably decided the C shell fits your requirements better. Deciding to use a Unix script at all means that the requirements of the program are rather simple, such as automating the usage of either standard or custom Unix tools. Complex logic or speed sensitive functions should be written in a more appropriate language as custom tools. Nowadays, tcsh, a compatible descendant of C shell, is more commonly used. This book will cover both versions. Setup and Installation Running on Linux Running on Mac OS X Learning the Language 150px|right|Illustration of a literal sea shell. Basics This section is about learning basic C shell to create small useful scripts. Useful for programmers of any level. How to create a script 25% — shebang, chmod, echo Using variables in a script 25%— set, quoting, wordlists Passing parameters to a script 25% — $argv, $0, $1, $2, $3 Parsing paths using variable modifiers25% — :h, :t, :r, :e Scripting defensively by trapping errors — if, -e, -d, -z, {cmd}, $status, exit Assembling the Unix tools to accomplish tasks — |, >, >>, cat, grep, cut Syntax 25% Comparison with Bourne shell Use of variables in the shell Arithmetic variables Expressions and true and false Boolean conditions Built-in variables Array variables Switch statements Cookbook Snippets 25% String manipulation — Slicing, Uppercase, Lowercase Number formatting— Formatting with Commas Example scripts Guppies — Port of a homework assignment to C shell. Password Generator — Human readable password generator Related books Guide to Unix/Explanations/Choice of Shell Resources The C Shell tutorial, eng.hawaii.edu - simple overview of C shell language The C Shell - warts and all, grymoire.com - list of gotchas with C shell C shell Cookbook by Malcolm J. Currie, starlink.rl.ac.uk Writing C shell scripts, University of Durham, dur.ac.uk Introduction to C Shell Programming, www-cs.canisius.edu An Introduction to the C shell, freebsd.org - William Joy's documentation UNIX Shell Differences, faqs.org USEFUL ONE-LINE SCRIPTS FOR SED, sed.sourceforge.net Uses of TR command, softpanorama.org - uppercase, lower case, rotate 13 SHELLdorado, shelldorado.com - Tons of scripts Wikipedia:C shell Wikipedia:tcsh Scripting languages C 25%