LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2005, 09:13 AM   #1
moodupani
LQ Newbie
 
Registered: Aug 2005
Posts: 12

Rep: Reputation: 0
bash


hi,
do I need to add echo lines on this answer?

Write a bash script that takes the name of a directory as an argument and searches the file hierarchy rooted at that directory for zero length files. Write the names of all zero length files to standard output. If there is no option on the command line, have the script delete the file after displaying its name. An -i option on the command line indicates that the script should ask the user for confirmation before deleting the file.

$ cat zerdel

if [ $1 == -i ]

then

find $2 -empty -print -exec rm -i {} \;

else

find $1 -empty -ok rm -i {} \;

fi
 
Old 09-08-2005, 09:21 AM   #2
slackie1000
Senior Member
 
Registered: Dec 2003
Location: Brasil
Distribution: Arch
Posts: 1,037

Rep: Reputation: 46
hi there,
mate, you open 10 threads asking homework questions..
it is against the rules..
regards,
slackie1000
ps. reported..
 
Old 09-08-2005, 04:47 PM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
From what I can tell no echos are needed, find should write out the filenames., but you should have answered the question yourself when testing your script. Your $1 and $2 scheme may work, but when parsing command line options in shells 'getopts' is the perferred way. Search this site or google, there are lots of examples.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
$LINENO can't be modified in bash 3.0, while it can be in bash 2.05b Darwish Linux - Software 1 11-07-2005 02:57 PM
Bash Echo Kilo Linux - General 3 11-02-2005 11:11 PM
bash help brianbek Linux - General 2 04-03-2005 06:03 PM
bash + html + javascript or just bash ? rblampain Programming 4 12-01-2004 07:53 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration