Solved

continuing towards writing more complex and usable scripts

Posted on 2004-09-26
5
237 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Host to IP 7 77
noX challenge 17 91
unix example issues 18 75
how to use laptop or pad camera in vb.net windows application 2 50
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

23 Experts available now in Live!

Get 1:1 Help Now