Solved

continuing towards writing more complex and usable scripts

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to ask for filename column 8 37
sum13 challenge 24 107
modThree challenge 4 91
abstract class with all non abstract mentods 6 76
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

809 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