Sponsored Content
Full Discussion: Bash Script Help Needed
Top Forums Shell Programming and Scripting Bash Script Help Needed Post 302982374 by wviands on Wednesday 28th of September 2016 11:54:00 AM
Old 09-28-2016
Bash Script Help Needed

I have a small script I wrote to look for empty files on a Linux box. It finds the empty files and emails the list to me. That works great. What I need to do now is set a cron job to run the thing every 10 minutes or so (no problems there) but I don't want to get any more emails if the last email has the same contents as the last time the script ran. Does that make sense? I only want to get new email if there is a change in the number or names of the empty files it finds.

Thank you for any input. I stink at scripting of any kind.


Code:
#!/bin/bash

FQDN=`/bin/domainname -f`
FILE=/tmp/$FQDN.`date +%F`.txt
exec &> $FILE
dir=/home/
COUNT=`find $dir -type f -empty | wc -l`

if [ ! -f $FILE ]; then

echo " "
echo "The following files are empty... "
echo " "
find $dir -type f -empty
echo " "

mail -s "I Have $COUNT Empty Files"  wviands@my.email < $FILE

fi


Last edited by vgersh99; 09-28-2016 at 12:57 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

debugging in bash!!! help needed

Hi all, Am using bash shell. Am newbie, trying to understand the debugin process of a shell script... I am unable to comprehend the control flow ,meaning from where exactly the execution of the script begins... I tried using bash-xv <scriptname> but since am new ,am finding it difficult to... (2 Replies)
Discussion started by: wrapster
2 Replies

2. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

3. UNIX Desktop Questions & Answers

Help needed tracing source of bash error

Issue resolved: The 'culprit file' was .bash_aliases. It had the naughty  (ASCII for the octal string Bash was detecting and returning an error about). I cleaned it up in Pico (see my post to the thread on favorite editors if you want background on why I use Pico/Nano), re-sourced it via... (0 Replies)
Discussion started by: SilversleevesX
0 Replies

4. Shell Programming and Scripting

Help needed with bash script providing battery status

I'm really new to even doing a bash "hello world" script, so maybe someone would know how to do the following task, using bash scripting Need to login using ssh from one dell server into another dell server, and obtain the raid battery status, using dell's open manage software commands; then... (5 Replies)
Discussion started by: AJ-102111
5 Replies

5. Shell Programming and Scripting

bash if statement help needed

Hi I need a script with an if statement that goes. I need it to search through all files within a directory with the extension .test if it finds the string '71502FSC1206' then do sed 's/71502FSC1206/\n&/g' > send.test If it finds the string '715MCH' or '715JAC' then I need it to move the... (1 Reply)
Discussion started by: firefox2k2
1 Replies

6. Homework & Coursework Questions

Linux/UNIX Bash Shell Script trouble help needed!!

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 2. Shell Bash Script 3. !/bin/bash if echo no directory then mkdir -p /home/AC_Drywall elif ; then echo "$dir already exist" fi (4 Replies)
Discussion started by: TomFord1
4 Replies

7. Shell Programming and Scripting

Help needed on ssh in bash scripting

HI I have the following requirement I have a script a.sh which will deploy files in multiple servers .The argument for the a.sh is abc.gz host1.conf where abc.gz is a zip file and one.conf will contain all the database connection string . Now I have to write a b.sh which will... (7 Replies)
Discussion started by: harry00514
7 Replies

8. Shell Programming and Scripting

Input password to bash script, save, and enter when needed

I am looking for a way to start a script and have it prompt for a password that will be used later on in the script to SSH to another host and to SFTP. I don't want the password to be hard coded. Below is my script with the actual IP's and usernames removed. #!/usr/bin/expect -f... (2 Replies)
Discussion started by: jbrass
2 Replies

9. Shell Programming and Scripting

Question related to bash. Your help needed.

Dear Team, i have one question related to automation of adding new users based on txt file. Here we go: I have data.txt file which shows: bang dang benc One by one, after pressing enter. And now, I need scirpt which will add those users with home directory hidden within the file... (7 Replies)
Discussion started by: protos27
7 Replies

10. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies
STG-NEW(1)							   StGit Manual 							STG-NEW(1)

NAME
stg-new - Create a new, empty patch SYNOPSIS
stg new [options] [<name>] DESCRIPTION
Create a new, empty patch on the current stack. The new patch is created on top of the currently applied patches, and is made the new top of the stack. Uncommitted changes in the work tree are not included in the patch -- that is handled by linkstg:refresh[]. The given name must be unique in the stack, and may only contain alphanumeric characters, dashes and underscores. If no name is given, one is generated from the first line of the patch's commit message. An editor will be launched to edit the commit message to be used for the patch, unless the --message flag already specified one. The patchdescr.tmpl template file (if available) is used to pre-fill the editor. OPTIONS
--author "NAME <EMAIL>" Set the author details. --authname NAME Set the author name. --authemail EMAIL Set the author email. --authdate DATE Set the author date. -m MESSAGE, --message MESSAGE Use MESSAGE instead of invoking the editor. -f FILE, --file FILE Use the contents of FILE instead of invoking the editor. (If FILE is "-", write to stdout.) --save-template FILE Instead of running the command, just write the message template to FILE, and exit. (If FILE is "-", write to stdout.) When driving StGit from another program, it is often useful to first call a command with --save-template, then let the user edit the message, and then call the same command with --file. --sign Add a "Signed-off-by:" to the end of the patch. --ack Add an "Acked-by:" line to the end of the patch. STGIT
Part of the StGit suite - see linkman:stg[1] StGit 03/13/2012 STG-NEW(1)
All times are GMT -4. The time now is 09:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy