Talkback for article: 216, September2001

Shell Programming

Back to:

From: ray hartman <rayhart(at)> [ date: 2001-09-04 ]
The "SHELL" huh ... nothing wrong with the CLI long as it reads
like a Ray Chandler short story --- but instead it spews stray-dogs-on-sterno howling complete with
code that looks like doodles from a spastic codeine addict
and punctuation marks rather than memes ... gag me there the fsck is REXX
when we really need it. Now ... what don't you understand about the failure
of Linux on-the-desktop ???
From: Marc Cook [ date: 2001-09-04 ]
Ray Hartman, you don't have to use the shell when you don't need it.
....but if you want you have a really powerful programming tool
to solve all kind of problems within seconds.
The bash is not the Linux desktop! What we still need is good and stable office applications

Very good article!
From: Dan Kegel <dank(at)> [ date: 2001-09-30 ]
Good looking article. People looking for books on the subject
might want to look at my bibliography at
From: kwoff [ date: 2001-09-30 ]
Nice, useful, get on your feet quick article.
Contrast this with the useless I-like-hearing-myself-babble
talkback above by ray hartman.

Someone who wants to do shell scripting could read this
article to start playing around, then when they read
`man bash` they might feel less overwhelmed.

From: MH [ date: 2001-10-03 ]
Great article. Concise, yet clear. Better resource for beginning shell programming than most chapters in reference books I've read. MUCH better than slogging through the man pages!
From: Dan G <dangustafsson(at)> [ date: 2001-10-04 ]
Clear and concise advise. Thank you for sharing.
From: Stephen Rossiter <CSM3014(at)> [ date: 2001-10-04 ]
is there programming in setting up a Linux lab a one printer
From: Muhammad Kamran Aslam Rana <creative28pk(at)> [ date: 2001-10-05 ]
really i like Unix family, but i have a lot of problem, my first problem my monitor belongs to Older family therefor Linux not detect it, and the 2nd problem is, my modem not install, the 3rd problem is Sound card not install, therefor i turnOut towords windows,
Modem=Planet "fax/data/voice 56k PCI INTERNAL MODEM"
Sound card=YAMAHA724
AGP=Trident 9750 3d image PCI/AGP
so i am really thanks full to u if u solve my problem,
thanking U, creative28
From: harry <harry_sices(at)> [ date: 2001-10-08 ]
great article. I am looking for a way to assign a value to a variable from
the result of a pattern search of a text file (either from grep or gawk or
a similar type of command).
Is there a way to do this with linux? Thanks
From: Thomas Lösche <thloesche(at)> [ date: 2001-10-11 ]
Hi harry,

you could solve your problem with the following comands

var=$(( grep 'pattern' file ))
var=`grep 'pattern' file`

cu Thomas
From: buffer_7 [ date: 2001-10-17 ]
Hallo !!

Ich schreibe mal deutsch, da der Artikel auch deutsch war.
Der Artikel ist genial und hoffentlich kommen mal wieder'n paar Jungfüchse
auf den Geschmack und programmieren wieder in Shell.

A B E R !!!!!

Mit dem von Dir gezeigten Hashbang (#!/bin/sh)werden die Leute Probleme bekommen.
In fast allen Linuxdistributionen ist /bin/sh ein Link auf /bin/bash.
Somit funktioniert alles so wie von Dir vorgestellt.
Sollte jetzt aber jemand an Unix sitzen oder aus irgendeinem anderen Grund
tatsächlich eine sh starten, dann werden Ausdrücke wie ${variable} nicht aufgelöst.
da muß der Ausdruck in den von Dir vielzitierten Backticks (`) liegen.
Sonst findet keiner den Fehler, da die Shell lapidar meldet bad Substitution ${ .
Aber trotzdem ein sehr guter und kompetenter Artikel. Es macht Freude sowas zu lesen.
Weiter so mit Eurem Magazin und so tollen Artikeln.

Gruß und Kuß
From: nickydhruv <gutentag24(at)> [ date: 2001-11-01 ]
Thanks for the simple and comprehensive article :)

From: nainala srinivas <sri_nainala(at)> [ date: 2001-11-19 ]
From: Bill Tyler <billtyler(at)> [ date: 2001-12-09 ]
Great article, easy to understand.
From: balu [ date: 2001-12-18 ]
It is very good for the starter I learend something new from this.Thanks All
From: Arthur Jovellas <art(at)> [ date: 2002-01-03 ]
Hello, I am trying to do a "lynx -dump" from a shell script and it is hanging.
It has been a while since I have programmed and I know it's something stupid.
I have made the script executable. I just want the script to dump a site to
a file like so:

lynx -dump > sitedump

From just a commandline it works fine but I cant seem to call it correctly from the script.

I guess I just need to know how to call binaries correctly.

Any suggestions appreciated. Please email me


Good article!

From: guido [ date: 2002-01-03 ]
Hi Arthur,
if it works from the command line then

lynx -dump > sitedump

will work from the shellscript as well. However
dependent on how you run the script and what you set in the script
it will not see the same environment variables (PATH, http_proxy, no_proxy ...)

From: Andreas Gebauer <g.farmer(at)> [ date: 2002-01-23 ]
Sehr guter Artikel , hab ihn nur kurz überflogen und sofort beschlossen ihn auszudrucken.

From: Atul Kansara <atulkansara(at)> [ date: 2002-02-03 ]
Sehr guter Artikel , hab ihn nur kurz überflogen und sofort beschlossen ihn auszudrucken.

From: Robert Agustin [ date: 2002-02-19 ]
I want my password not visible when you type. I would like to know how
to code/script this.
From: z wang <> [ date: 2002-05-10 ]
very good artical. I enjoy it very much and it helps me a lot.
z wang
From: Nir Soffer <nirs<at>> [ date: 2002-05-12 ]
Very good article, thanks.
From: Juan Pablo Feria <feria(at)> [ date: 2002-05-21 ]
Great Article..

Congratulations from Mexico!

From: sundar <sun2379(at)> [ date: 2002-06-08 ]
Hey guys iam workin on solaris(new to solaris) as well as in vax environ.. if anybody have any information bout shell prog/kernel prog, plz help me where i can find more documents and infos.. this site was usefull to me and couple of links from this page helped me find info on basic shell prog.. so thanx in advance...
From: Ganapathi <gsn_msst(at)> [ date: 2002-07-22 ]
I got a over all basic idea about the shell programming using
the site.Thax and bye.
From: Innocent Azinyue <azinyue(at)> [ date: 2002-07-25 ]
Actually I have a question... When I try running the script, I get some stupid errors
For instance when I do

if [$# -lt 3]; then

# is being recongnized as a commented line. Why is that ?!?

From: guido socher [ date: 2002-07-26 ]
Hello "Innocent Azinyue",

Space matters! Try
if [ $# -lt 3 ]; then
instead of
if [$# -lt 3]; then

Read also the part on "Control structures" in the article
there this is mentioned.
From: siva basava k [ date: 2002-08-04 ]
Very good article . Very useful for beginers.
From: critter <critter(at)> [ date: 2002-08-07 ]
Wonderful page! Very useful. Good examples and short ant reasonable explanations!

From: Harshad <hnl_me(at)> [ date: 2002-08-13 ]
It's very much useful things for the new user for unix. You have done well I learnt many things from your web-site for the unix.
But, still I have some confusion about the Kernel. What is kernel ? and I also want some more shell script examples. So I can clear myself.

Thank You very much..

Reply Soon.
From: Running shell commands form a script <jagannathasuta(at)> [ date: 2002-08-25 ]
I would like to konw why a command like PS1='$PWD $' will not run in a shell script. All of my other commands run fine.
From: Jose Manuel Robelto <jrobelto(at)> [ date: 2003-01-14 ]

many thanks for this articule, i find all here, i learn many new thing about unix here...

my mail is
From: B Wheat <dr_b_2groovy(at)> [ date: 2003-02-07 ]
I really enjoyed your article, though becase I'm still very much a newbie I would like a lot af help thanks
From: Ashwani <desperado1306(at)> [ date: 2003-04-21 ]
Very helpful article with nice attempt to make fndamentals of Shell programming clear, I learned greta deal from this .... thanks to both the authors!
From: Anju <anju.aggarwal(at)> [ date: 2003-04-28 ]
A very useful article indeed
I am a beginer in the Unix field. I tried to run the script to convert from binary to decimal. My problem is that the command 'echo -n $1 |wc -c ' running fine on command line but giving erronous result when run thro' script. Can any of you help me in finding the solution to this strange behaviour . thanx in advance

From: oguzhan ceylan <sopho24(at)> [ date: 2003-05-01 ]
thanks for all article. It worked very hard for me....:)
From: Biplab Chattopadhyay <biplab_1979(at)> [ date: 2003-06-18 ]
Mostly such small tutorial sort of things I read, will start from very basic them suddenly will jump to such complexity that I will be puzzeled and I will have to refer to some book to get that. But here the good thing I found was that the transition I could not feel. Its good one..
From: chh <darkavenger(at)> [ date: 2003-09-15 ]
I like the examples in this great article!


From: sanjeev kumar <san_007(at)> [ date: 2003-11-10 ]
hello sir
please u tells me about the all shells in details
From: jigisha <j_maruti(at)> [ date: 2004-01-23 ]
How to create multiple users at a time by shell programming.
From: reshma [ date: 2004-03-31 ]
very good article..!! for beginners
From: Chandrashekhar <rush_to_shekhar(at)> [ date: 2004-06-10 ]
Please guide me i want to master shell programming
From: Koneru <pkoneru(at)> [ date: 2004-06-16 ]
Can I use the if statement as shown below to check if the files
with names beginning with jnlupload are existing ??

if [[ -f $PS_DATAHOME/glr1140_20/jnlupload* ]]; then

From: Paul C [ date: 2004-07-01 ]
Thanks for the article. Very well written with good examples.
From: devaraju <deva_1002(at)> [ date: 2004-07-03 ]
unix shell programming
From: loius <loius_757(at)> [ date: 2004-07-07 ]
I want ask you one question??
Question:how to write the shell script move *.html to *html.old???
From: thomas <tzz33v(at)> [ date: 2004-07-15 ]
This is very useful for those (like me) who are beginners in shell scripting.
From: Albert J Reily [ date: 2004-07-27 ]
Great work. Keep it up!
From: Sriharsha <vsriharsha(at)> [ date: 2004-08-03 ]
A remarkably well-written article. Equips you with all that is needed to understand and develop scripts. Maybe ppl are looking for GUI based stuff, but CommandLineInterface is not doomed yet.


Keep going....
From: pratap <pratapb(at)> [ date: 2004-08-16 ]
It's a very nice article for UNIX bignners ,very thank full to the creater
of this article.
From: great article! [ date: 2004-08-22 ]
Thank you for refreshing tutorial on BASH.

It complements my study with Quigley's Linux Shells by Example and Forta's Regular Expressions.

From: Murho [ date: 2004-09-03 ]
Das ist ein schönes Website ... es gefällt mir sehr !
Mit viele Grüsse,
murho -> linux newbie.

From: chandra reddy <creddy_m(at)> [ date: 2004-09-13 ]
It is very useful to biginers.
Thank you
From: Manoj Kumar Mishra <Manoj(at)> [ date: 2004-09-21 ]
I encountered a problem when i am writting a shell script to add two digit number and a 10 digit number. it is working perfectly with a 9 digit number. so i want to know that is there any data type is there in shell programming or not and if it is there what is the limit for that. I think it should be atleast 32 bit long. so max value can be 4294967295 which is 10 digit number (unsigned). if it is signeed then max value is 2147483647.
i want to know whether there is aomething signed or unsigned concept is there in shell programming or not.

please help me out if anyone know something about that.

thanks in advance.
From: RajilaTR <rajilatram(at)> [ date: 2004-09-24 ]
Very useful for beginers...............
From: prasad [ date: 2004-10-05 ]
This is very good article for unix shell scriping
many thanks for u r great help

From: JP <jpvarg(at)> [ date: 2004-10-20 ]
I like the examples in this great article!


From: anthony <unsafespy2(at)> [ date: 2004-10-25 ]
I am a beginner and I just wrote a basic script to remind me to pay my bills for the how do i write the same script using the if/elif/else..
From: John Thompson Jr. <ktone_1(at);> [ date: 2004-11-04 ]
Hello I need help.

I'm trying to pass information from one file to a variable within an ifthen statement. ex: if ["$a" = "$1"];then ....

$1 is defined on the command line. $a is getting informataion from ps-aef. Any suggestions??
From: arwoy digna <arwoy_digna(at)> [ date: 2004-12-09 ]
i have a question ?how to write a shell prompt in pico,that is:
Write a program that asks the user to enter a base value followed by a decimal integer value. It then prints out the converted value to the specified base. You may print out the new digits in list form (comma separated). The program should repeat this process of asking for two numbers and printing the answer until the user enters zero for the base.
Enter a base number (or zero to quit): 8
Enter a decimal value to be converted: 255
The decimal value 255 in base 8 is [3, 7, 7]

Enter a base number (or zero to quit): 2
Enter a decimal value to be converted: 19
The decimal value 19 in base 2 is [1, 0, 0, 1, 1]

Enter a base number (or zero to quit): 0

From: Suddha Satta Ray <ssray23(at)> [ date: 2004-12-10 ]
Wonderful article on Shell. I learnt a lot here.
Infact, this site has become like a mini-reference for me!!!
The examples are well chosen.

From: Charlie Macchia <cmacchia(at)> [ date: 2005-02-03 ]
Quickie - in the bash shell on OSX (FWIW), the conditional command -f does not appear to work if the path to the file, is included with the file name, thus:

if [ -f "/Users/Chaz/afile.txt" ] will fail no matter what, but

if [ -f /Users/Chaz/"afile.txt" ] works fine.

I've noticed on your site this example

Shortcut operators
People familiar with C will welcome the following expression:

[ -f "/etc/shadow" ] && echo "This computer uses shadow passwors"

if the issue above is generalized to Linux bash, then the [ -f "/etc/shadow" ] will also fail no matter what.

thought it was worth mentioning

Great site BTW

From: shanmugam.s <kingshanmugam(at)yahoocom> [ date: 2005-04-05 ]
thanks for all helps

good day
From: John Vogel <john55gc(at)> [ date: 2005-10-27 ]
I would like to know how to run a 'C' function from a Unix script?
From: Kris W [ date: 2006-07-04 ]
As someone new to shell scripting, and someone who hates any tutorial that starts with the "hello" script.
This has been a rgeat deal more informative than any of the other regurgitations available on the net

From: Stu Gillis <sfgillis(at)> [ date: 2006-07-20 ]
I would like to point out a small error in your Backtick explanation.

You give the command to archive files as
tar xvf file.tar infile1 infile2 ...
instead of
tar cvf file.tar infile1 infile2 ...

A minor thing to be sure, but it could be confusing to a someone new.

Overall an exceellant resource that I will pass on to our LUG as a link.

From: Ranga [ date: 2006-08-24 ]
I am new to Shell Scripting in Linux. This article is very helpful to me in understanding the various basic concepts. Thanks a lot to the Authors. can you add some more easy examples towards the end, if possible?
From: samer asbah <abutoto1983(at)> [ date: 2006-10-05 ]
i tried to learn shell script before , it was a little bit difficult to understand the basics before , but i think that this page was so helpfull.

Thanks a lot to who write it and to who support him

68 talkbacks in English
Other talkbacks:   Portugues Francais

Due to the increased amount of web spam we have deciced to removed the talkback posting possibility. You can read old talkbacks but you can no longer post new ones.

Back to

Please contact webmaster(at) if you have any questions with regards to this talkback

lftalkback version 3.10