Sponsored Content
Full Discussion: for loop problem
Top Forums Shell Programming and Scripting for loop problem Post 302161620 by V3l0 on Friday 25th of January 2008 08:33:43 AM
Old 01-25-2008
Hello,

First, when you select "*log*", you don't have to select "*.log*" beacause they are already in the first selection !

Second, why "touching" the file before deleting it ?

Third, your script will be runnig with "unable to remove file xxx" beacause of the command "rm -f $filestodelete" that will delete all the files selected by "for files in (*log*|*.log*)"

So, I propose you the script :
Code:
list=$(ls *log*)

for file in $list
do
    cp $file $file.$(date +%a)
    rm -f $file
done

 

10 More Discussions You Might Find Interesting

1. Programming

problem with while loop

hi all, i have written the following code: while(proceed !='Y' && proceed!='N' && proceed!='y' && proceed!='n') { printf("\nPress \n\t 'Y' or 'y' to continue \n\t 'N' or 'n' to cancel:"); scanf("%c",&proceed); } the output i am gettin is: Press 'Y' to continue ... (1 Reply)
Discussion started by: mridula
1 Replies

2. UNIX for Advanced & Expert Users

loop problem

Hi guys my while do loop is not working properly; As soon as the load_date and run_date is same it should stop can somebody tell me where I am having the problem? In an oracle table I have LOAD_DT=5/1/2009 DATE datatype RUN_DT=5/5/2009 DATE datatype Now in a script with a spool file I get the... (15 Replies)
Discussion started by: henrysmith
15 Replies

3. Shell Programming and Scripting

Problem in While loop

Hi Guys, This is my code.. I am getting an error in the inside while statement when comparing.. I am not able to figure it out.. Pls help me... while read value fatherid son_id top_id r_type do inside_value=1; echo $inside_value; echo $r_type; while do echo... (6 Replies)
Discussion started by: mac4rfree
6 Replies

4. Shell Programming and Scripting

problem with a loop

Hi What is wrong with this loop it was taken has a example in book!!! it returns then /usr/sbin/svcadm disable ppserv else /usr/sbin/ppadmin stop fi } (3 Replies)
Discussion started by: Ex-Capsa
3 Replies

5. Shell Programming and Scripting

problem with while loop

hi I had created a while loop in a script file called whiletest.sh as follows as follows: count=0 max=10 while do echo $count echo count=$(count+1)" " done echo "value of count:$count" then i run the script with the command sh whilestest.sh but its giving me an error... (5 Replies)
Discussion started by: angel12345
5 Replies

6. UNIX for Dummies Questions & Answers

While loop problem

I have a while loop with -f and -o option.Can any one please tell me what that stands for?The Sample code is as follows:- while do ## some processing done (10 Replies)
Discussion started by: Param0073
10 Replies

7. Shell Programming and Scripting

Problem with While loop.

Hi Script Gurus, I am facing issue with while loop in bash. The while loop is running as end less loop even after given criteria does not meet. STATE_BEFORE_SPLIT () { for clone in $Clonegroups; do state=$( $Navicmd -listclone -name $clone -cloneid $Cloneid |awk... (3 Replies)
Discussion started by: RobP
3 Replies

8. Shell Programming and Scripting

Problem with loop within loop

Hi, I work on Ab-initio ETL tool which is based on Unix. I made a small script which has two loop's one with in another. All the functionality is working for the first line of outer loop but when it comes to other lines of outer loop it is throwing error as command not found. Below is the... (4 Replies)
Discussion started by: Ravindra Swan
4 Replies

9. Shell Programming and Scripting

Problem with While Do loop

I am trying to do a while do loop that asks for a password and returns if the password entered is incorrect. I have that part working however i want to modify it so that if a similar word is entered it will read "that is close but incorrect" and i cannot seem to get it working, being new in the... (6 Replies)
Discussion started by: lm5522
6 Replies

10. Shell Programming and Scripting

Problem with loop

Hi all, a problem with a loop. Imagine it starts with var1="$(cat txtif.out )"while do echo file1 echo file2 echo y > txtif.out if then break fi done exit 0 the problem is that if the file is changing during the loop seems to continue as it reads "x" state,... (5 Replies)
Discussion started by: Board27
5 Replies
cmannotifyd(8)						     CMAN Notification Daemon						    cmannotifyd(8)

NAME
cmannotifyd - CMAN Notification Daemon SYNOPSIS
cmannotifyd [-f] [-d] DESCRIPTION
The cmannotifyd daemon talks to CMAN and provides a mechanism to notify external entities about cluster changes. CMAN dispatches 3 kind of notifications: - CMAN_REASON_TRY_SHUTDOWN when cman requests to all clients if it is allowed to shutdown. - CMAN_REASON_STATECHANGE when cman detects a node joining or leaving the cluster. - CMAN_REASON_CONFIG_UPDATE when a configuration change event has been detected/requested. These notifications are then dispatched to the shell script cman_notify in the environment variable CMAN_NOTIFICATION. cman_notify will then execute all the scripts in the configured notification directory (default: /etc/cluster/cman-notify.d) passing a very minimal set of envvars including, of course, the CMAN_NOTIFICATION= type. The execution order is set by the filename as shown by "LC_ALL=C ls -las". cmannotifyd logs are stored in the default log file (/var/log/cluster/cmannotifyd.log). cman_notify logs are stored in the default log file (/var/log/cluster/cman_notify.log). By default the output from the scripts executed by cman_notify is redirected to /dev/null. Users can either set CMAN_NOTIFICATION_DEBUG=1 in their environment or set proper debug configura- tion in cluster.conf to redirect scripts output to the cman_notify log file. NOTES
cmannotifyd does not block on cman_notify nor check the exit status of the script. Notifications are dispatched in the same order as they arrive, one by one. CMAN_REASON_TRY_SHUTDOWN is passed to scripts for information only, they can not influence cman's decsion about whether or not to shut down. CMAN_REASON_STATECHANGE also implies CMAN_NOTIFICATION_QUORUM exported in the environment. CMAN_NOTIFICATION_QUORUM will be set to 1 (when the node is part of a quorate cluster) or 0 (otherwise). A template for cman_notify scripts can be found in the doc/ directory. OPTIONS
-f Run in the foreground (do not fork / daemonize). -d Enable debug output. November 2008 cmannotifyd(8)
All times are GMT -4. The time now is 01:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy