script that will list .c programs


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers script that will list .c programs
# 1  
Old 08-31-2005
script that will list .c programs

hey, im trying to write a script that will list all the .c files, and give me the first 10 lines of code in them. I think ive got that bit working, but i want to make it use friendly so i can select whether i want to modify a .c file or delete it.
# 2  
Old 08-31-2005
Post the script you have so far.

Vino
# 3  
Old 08-31-2005
all ive written so far is this:
!# /bin/sh
find *.c -print > file.txt
cat file.txt

it seems to be working
# 4  
Old 08-31-2005
Code:
#! /bin/sh

find /dir/to/search -name '*.c' > file.txt

while read file
do
echo "First 10 lines of $file are "
head $file

echo "
Press d/D to delete $file 
Press m/M to modify the $file"

read reply

case "reply" in 
"d|D") rm -f $file 2> /dev/null ;;
"m|M") vi $file ;;
"*") echo "Do nothing with $file" ;; 
esac

done < file.txt

Not tested.

Vino
# 5  
Old 09-01-2005
your code was helpful, but i had to modify it a bit, and it never did stop and ask for the user input.
would /c stop the loop and let the user enter input?
# 6  
Old 09-01-2005
Quote:
Originally Posted by Saggas
your code was helpful,
Code:
but i had to modify it a bit, and it never did stop and ask for the user input.

would /c stop the loop and let the user enter input?
I am confused.

Never stopped asking for user input i.e. run into infinity ? Or never asked for user input, at all?

Whats /c ? You mean CTRL-C ?

Can you post the modified script ?

vino

Last edited by vino; 09-01-2005 at 09:38 AM..
# 7  
Old 09-01-2005
no the program just ran and ended, it printed the message asking if i wanted to delete it but it ended without letting me choose.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Difference between inbuilt suid programs and user defined root suid programs under bash shell?

Hey guys, Suppose i run passwd via bash shell. It is a suid program, which temporarily runs as root(owner) and modifies the user entries. However, when i write a C file and give 4755 permission and root ownership to the 'a.out' file , it doesn't run as root in bash shell. I verified this by... (2 Replies)
Discussion started by: syncmaster
2 Replies

2. Shell Programming and Scripting

Specifying a list name as argument and using that list in script.

Is there a way I can specify the name of a list as an argument to a shell script and then use the values of that list name in the script? I need to do this WITHOUT using case statements. Something like this: check.sh list1 #!/bin/bash list1="www.amazon.com www.google.com"... (9 Replies)
Discussion started by: gctaylor
9 Replies

3. Shell Programming and Scripting

Using programs to open files from within the script?

I am suppose to make a program that cuts the extension off of a file. It uses that .ext to decide which program needs to be used to open the file. This only finds the name of the program from a list of programs I made. My problem is when it has the name of the program it needs to use, how can I... (2 Replies)
Discussion started by: dordrix
2 Replies

4. Shell Programming and Scripting

Interpretation of $variables inside programs run from a script

Hi, I am running a shell script that executes a program. Inside this program, variables are also referenced using a dollar symbol, eg. $a, $thething, and the shell script is misinterpreting them as variables relevant to the shell script rather than relevant to the program run from inside the... (2 Replies)
Discussion started by: TheBigH
2 Replies

5. Programming

Running programs from a Python script

Any idea how I can run a program from a phyton script? For example, in csh I will do $tpath/tsimplex base=$fbase data=$fdata restore=$frestore \ nxp=$nx nzp=$nz param=$param intp=$intp nlay=$nlay \ varp=$varp sigma0=$sigma maxiter=$maxiter tol=$tol \ ... (2 Replies)
Discussion started by: kristinu
2 Replies

6. UNIX for Dummies Questions & Answers

Are programs like sys_open( ) ,sys_read( ) et al examples of system level programs ?

Are the programs written on schedulers ,thread library , process management, memory management, et al called systems programs ? How are they different from the programs that implement functions like open() , printf() , scanf() , read() .. they have a prefix sys_open, sys_close, sys_read etc , right... (1 Reply)
Discussion started by: vishwamitra
1 Replies

7. Shell Programming and Scripting

Gen. Question - Script calls multiple programs - Return Code Handling?

General Question: If a script calls multiple external programs (external to the script, but still on unix), where do the return codes go? Let's say one of external programs fails, does the entire script fail and send a non-zero return code to the job scheduling software, or is the return code sent... (1 Reply)
Discussion started by: jnanasakti
1 Replies

8. UNIX for Dummies Questions & Answers

Creation of a script to launch several programs

I'm really new to this, so thanks for your patience... I've been trying to create a script to launch several applications at once. I've been researching books and forums, but I end up with more questions than answers. As much as I hate to say it, I don't know if I can figure it out on my own...... (3 Replies)
Discussion started by: j.middlefinger
3 Replies

9. UNIX for Dummies Questions & Answers

Where did my programs go?

I notice that (Mandrake) Linux and Windows do not seem to operate alike in terms of installing third party software. Windows, on one hand, creates icons and adds items to the Start Menu, with the help of the InstallShield--or equivalent, of course, but Linux, on the other hand, seems to care... (3 Replies)
Discussion started by: helvetica
3 Replies

10. Programming

How to Compile programs using cc??

How do you Compile programs using cc?? I'm lost. Do I need to buy C or what? I'm only going to use it very few times a year. From what everyone seems to be telling me, it sounds like it is build into the Unix system but I'm having no luck. Please help or just point me in the right direction. ... (7 Replies)
Discussion started by: spotanddot
7 Replies
Login or Register to Ask a Question