Sponsored Content
Full Discussion: Problems with Syntax
Top Forums Shell Programming and Scripting Problems with Syntax Post 302341499 by kshji on Thursday 6th of August 2009 05:00:33 AM
Old 08-06-2009
Code:
#!/bin/ksh
# or bash
# cleanscript
# arg1 = file, arg2= days

[ $# != 2 ] && echo "usage:$0 dirlistfile days" >&2  && exit 1

file="$1"
days="$2"
cat "$file" | while read line 
do
  find $line -mtime +$days -exec rm -f  {} \; 2> errors.txt
  # do cmd and put stdout to the var
  x=$( wc -l < errors.txt )
  # numeric testing builtin
  if  ((  x>0  ))
  # or using test or [  builtin command
  # if [ "$x" -gt 0 ]
  then
         mail -s "errors" someone@email.com < errors.txt
  fi
done

Code:
chmod a+rx cleanscript
./cleanscript dirlistfile  7


Last edited by kshji; 08-06-2009 at 06:05 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

'make' problems (compliation problems?)

I'm trying to compile and install both most recent version of 'make' and the most recent version of 'openssh' on my Sparc20. I've run into the following problems... and I don't know what they mean. Can someone please help me resolve these issues? I'm using the 'make' version that was... (5 Replies)
Discussion started by: xyyz
5 Replies

2. UNIX for Dummies Questions & Answers

What does this syntax mean...

OK, the title is a little vague, but basically i was gonig through some files and ran into some strange syntax... heres what it looks like: ... 1&>~/<file extension> where ... is a chain of commands (the 1&>~ is part of the arguments) and the file extension is just a pointer to a file... (1 Reply)
Discussion started by: DrAwesomePhD
1 Replies

3. Shell Programming and Scripting

Help with the syntax

export check=$(expandname $(dirname $(which $0))) (2 Replies)
Discussion started by: chandhar
2 Replies

4. Shell Programming and Scripting

Help with the syntax

can anyone explain the code for me... i am new to shell programming while getopts ":S:D:U:" OPTION "$@" do case $OPTION in S) SRVR=$OPTARG;; D) DB="$OPTARG"; USEDB="use $OPTARG";; U) UID=$OPTARG;; :) MISSINGOPTARG="$MISSINGOPTARG -$OPTARG";; ?) if then ... (2 Replies)
Discussion started by: chandhar
2 Replies

5. Shell Programming and Scripting

what is the right syntax ??

IN the book below example showed find /home/tolstoy -type d -print | Find all directories sed 's;/home/tolstoy/;/home/lt/;' | Change name, note use of semicolon delimiter while read newdir Read new directory name do mkdir $newdir ... (7 Replies)
Discussion started by: convenientstore
7 Replies

6. Shell Programming and Scripting

Regarding syntax

Hi All, What does this mean ${#var} (2 Replies)
Discussion started by: krishna_gnv
2 Replies

7. Shell Programming and Scripting

Problems with syntax in a loop (AWK)

Hi guys, I'm trying to loop through a number of files that is set by whatever is in a field. eg. The idea is to split FILELIST down into fields, it could contain 1 - 999 fields and it's bar delimited. I thought simple, count the number of fields in the field and then loop... (1 Reply)
Discussion started by: Peejay
1 Replies

8. UNIX for Dummies Questions & Answers

Syntax Help

Hi everyone, I got some code here that I've been working on, but I've gotten stuck. I cant figure out what is wrong with the syntax. sub cksum{ my $uint32_t = \buffer; my $word_count; my $bias; ( #uint32_t checksum = $bias $word_count = $bias while ($word_count>=0) ... (2 Replies)
Discussion started by: TeamUSA
2 Replies

9. Shell Programming and Scripting

Problems with variables syntax

Hi there I am really struggling :eek: to place a value in a variable with the following loop, having run out of ideas please can someone point me in the right direction? We first read two PIDs of a program (say calc) into an array, then we loop reading the details of those processes into a... (6 Replies)
Discussion started by: nathan.harris
6 Replies

10. Shell Programming and Scripting

EVAL syntax problems

Hi there As part of a larger script I need to put the output of an ls into a variable which has an incremental number. ie nathan@nathan-Vostro-1700:~$ eval 'proc'$val='`ls -ld /proc/9467`' nathan@nathan-Vostro-1700:~$ echo $proc0 dr-xr-xr-x 8 nathan nathan 0 2012-05-02 09:21... (3 Replies)
Discussion started by: nathan.harris
3 Replies
Locale::Currency(3perl) 				 Perl Programmers Reference Guide				   Locale::Currency(3perl)

NAME
Locale::Currency - standard codes for currency identification SYNOPSIS
use Locale::Currency; $curr = code2currency('usd'); # $curr gets 'US Dollar' $code = currency2code('Euro'); # $code gets 'eur' @codes = all_currency_codes(); @names = all_currency_names(); DESCRIPTION
The "Locale::Currency" module provides access to standard codes used for identifying currencies and funds, such as those defined in ISO 4217. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 4217 three-letter codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying currencies. The ones currently supported are: alpha This is a set of three-letter (uppercase) codes from ISO 4217 such as EUR for Euro. Two of the codes specified by the standard (XTS which is reserved for testing purposes and XXX which is for transactions where no currency is involved) are omitted. This code set is identified with the symbol "LOCALE_CURR_ALPHA". This is the default code set. num This is the set of three-digit numeric codes from ISO 4217. This code set is identified with the symbol "LOCALE_CURR_NUMERIC". ROUTINES
code2currency ( CODE [,CODESET] ) currency2code ( NAME [,CODESET] ) currency_code2code ( CODE ,CODESET ,CODESET2 ) all_currency_codes ( [CODESET] ) all_currency_names ( [CODESET] ) Locale::Currency::rename_currency ( CODE ,NEW_NAME [,CODESET] ) Locale::Currency::add_currency ( CODE ,NAME [,CODESET] ) Locale::Currency::delete_currency ( CODE [,CODESET] ) Locale::Currency::add_currency_alias ( NAME ,NEW_NAME ) Locale::Currency::delete_currency_alias ( NAME ) Locale::Currency::rename_currency_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Currency::add_currency_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Currency::delete_currency_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes man page. SEE ALSO
Locale::Codes Locale::Constants http://www.iso.org/iso/support/currency_codes_list-1.htm The ISO 4217 data. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 1997-2001 Canon Research Centre Europe (CRE). Copyright (c) 2001 Michael Hennecke Copyright (c) 2001-2010 Neil Bowers Copyright (c) 2010-2011 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-09-26 Locale::Currency(3perl)
All times are GMT -4. The time now is 07:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy