LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-28-2005, 09:16 AM   #1
moodupani
LQ Newbie
 
Registered: Aug 2005
Posts: 12

Rep: Reputation: 0
Bash script


hi people,
can you tell me if these ans. are correct?

thanks


1. How to write a shell script to look into this file and send a birthday-congratulation e-mail to relevant users at 1:00 a.m. every day. Make your script as short as possible.

#!/bin/sh DATE=`date '+%d-%m-%y'`

USERS=`grep $DATE /etc/bithdates awk -v

FS=":" '{ print $1 }'

FOR USER in $USERS

do

echo "Happy birthday !" | mail $USER



2)How to 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.

ans:

$ cat zerdel

if [ $1 == -i ]

then

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

else

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

fi
 
Old 08-28-2005, 10:23 AM   #2
dub.wav
Member
 
Registered: Aug 2003
Location: Norway
Distribution: FC4
Posts: 83

Rep: Reputation: 20
Why can't you just run the scripts and see if they work?
 
Old 08-28-2005, 10:31 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Have a look here:

http://www.homeworkspot.com/

Dave
 
Old 08-30-2005, 07:31 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Quote:

2)How to 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.
you could start with: man find
 
  


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
Bash Script zaicheke Programming 3 11-07-2004 06:32 PM
bash script how to? Lleb_KCir Programming 11 05-21-2004 07:03 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
bash script prob: how can i tell the script that a 'dd' has finished? Frustin Linux - General 2 04-02-2003 05:34 AM

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

All times are GMT -5. The time now is 06:15 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