Solved

continuing towards writing more complex and usable scripts

Posted on 2004-09-26
5
234 Views
Last Modified: 2013-12-26
I've started writing shell scripts just one or two months ago...so basically i'm very new to it.
Now the question that i want to ask...how can i go for writing scripts that can perform operation of basic utility programs, i.e, whether one can write a script whose output are like that of ls, wc, grep etc commands.

Plz guide me...
0
Comment
Question by:abhishek_2707
5 Comments
 
LVL 11

Expert Comment

by:avizit
ID: 12154307
i think ls, wc , grep etc are  c programs ,
you can "use" those commans in your shell scripts ..

to write programs like wc , you should be doing coding in a high level language like c, c++

on the other hand you can also move forward by writing scripts and thereby automating your daily work

as forme .. nowadays I try to avoid coding in high level languages , by doing my work in perl etc ..
0
 
LVL 11

Expert Comment

by:avizit
ID: 12154313
0
 
LVL 9

Expert Comment

by:HamdyHassan
ID: 12155156
My advice to you, continue your learning by start Perl scripting, you will find a lot to learn , lot of fun
0
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 12155737
The whole philosophy of Unix programming is:
"many small, very specialized programs, that can be assembled into solutions."
and shell scripts are the glue that is used to assemble the components.
So the shell languages are designed to run the ls, wc etc commands and use
grep, awk, cut, sed, etc to parse the outputs.


0
 
LVL 16

Accepted Solution

by:
manav_mathur earned 50 total points
ID: 12197834
Continuing on brettmjohnson's concept,
almost everything that you will come across in UNIX is a file. Even the devices attached to your system can be considered to be files.

Normally, in shell scripting, what remains is file manipulation. UNIX provides many built in utilities lile ls, wc etc. for that which are precompiled C binaries(read executable files). You can find them all in the /dev/bin directory. (for that matter, in UNIX even a directory is a file!!) These binaries perform small independent tasks.

The existing binaries have been optimally designed and normally you dont try to 'reprogram' them or use your own code. They offer plenty of options in the form of commandline arguments/switches.

man <command>

will give you a complete listing of all the arguments that the command accept and usually that is more than enough for even the most complex scripts.
It is a matter of combining the funcitoanlity of the available commands in a shel script for your purpose.

For advanced text manipulation, learn PERL. It proves very sueful in the long run as Im realizing now :)

Cheers
Manav
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 47
sumDigits challenge 9 98
has77  challenge 9 68
Sed question 2 49
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now