Sponsored Content
Full Discussion: Recycle Bin Script
Top Forums Shell Programming and Scripting Recycle Bin Script Post 302318143 by chueu on Thursday 21st of May 2009 12:09:41 AM
Old 05-21-2009
code so far

Code:
#! /bin/sh



#-----------RECYCLE BIN------------

#set default
count=false
verbose=false
dir=`pwd`

#set date format
#month= `date +%m`
#year= `date +%Y`

#date= ` expr $year \*100 + $month `

#user input
in_date=false
in_year=false
in_month=false

#if no argument
if [ $# -lt 1 ]
   then
        echo "Usage: recycle_bin [ -dyymm ] [ -yyy ] [ -mmm ] [-h] [-v] [-c] [-x] [directory]"
fi

#when there is argument
while getopts :d:y:m:shcvs:x: $1
        do
                #create recycle directory
                #mkdir recycle
        case $1 in
                d) #search files by date yymm
                  echo "Files by Date YYMM"
                  date = $OPTARG
                  in_date=true
                  gyear=" ` expr substr $date 3 2` "
                  gmonth=" ` expr substr $date 1 2` "
                  ;;
                y) #search files by year yy
                  echo "Files by Year YY"
                  year = $OPTARG
                  in_year=true
                  yyear=" `expr substr $year 1 2` "
                  ymonth="`date +%m`"
                  ;;
                m) #search files by month mm
                  echo "Files by Month MM"
                  month = $OPTARG
                  in_month=true
                  mmonth=" `expr substr $month 1 2` "
                  myear="`date +%Y`"
                  ;;
                h) #list 5lines of files
                  echo "Files by Lines"
                  headFiles
                  {
                        file= `find $dir -maxdepth 1 -type f -mtime +$day -print`
                        count=0
                  }
                  ;;
                c) #number of files removed
                  echo "Total Number of Files"
                  count=true
                  countFile
                  {
                        if [ count != 0 ]
                           then
                                echo $count files moved
                        fi
                  }
                   ;;
                v) #search by modification
                   #echo "Verbose Option"
                   #verboseM
                   #{
                        #if [ $1 = ]
                   #}
                   echo "File(s) by modification"
                   ;;
                x) #no value
                   echo "Usage: recycle_bin [ -dyymm ] [ -yyy ] [ -mmm ] [-h] [-c] [-v] [directory]"
                   exit 0
                   ;;
        esac
        done


#--------OPTION D



#--------OPTION M



#--------OPTION Y

 

9 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

Path of Recycle Bin on Windows

hello everybody, I am trying to find the path of the Recycle Bin. I know that it's a temporary storage place, but it should have a path that we can refer to. I want to know it because I sometimes use cygwin to work on Windows, and when you delete something with it, it's gone. I just checked... (4 Replies)
Discussion started by: milhan
4 Replies

2. Shell Programming and Scripting

intro to UNIX - making a sort-of recycle bin (for fun)

Hello, I'm only taking Intro to UNIX in school right now, so please bear with me. My problem is with a sort-of recycle-bin rig I've created for fun. I'm using Ubuntu 9.04, I am the admin. (only user, actually) of this computer. I'm using this script in ~/.bashrc # if files exist, remove contents... (6 Replies)
Discussion started by: jzacsh
6 Replies

3. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies

4. Homework & Coursework Questions

UNIX Recycle Bin - restore function

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: A set of Linux shell scripts is required to allow users to ‘remove' files without them really disappearing until... (8 Replies)
Discussion started by: burn88
8 Replies

5. UNIX for Dummies Questions & Answers

Help with my recycle bin code

Hi~ I have a problem with my recycle bin code. #!/bin/bash if test !-d ~/.recyclebin #if recycle bin does not exists then mkdir ~/.recyclebin # then create recycle bin else mv $1 ~/.recyclebin #else move the deleted file in the recycle bin fi so when I... (10 Replies)
Discussion started by: zel2zel
10 Replies

6. Shell Programming and Scripting

Recycle Bin

what is recycle bin mode in unix??? (4 Replies)
Discussion started by: arun508.gatike
4 Replies

7. Shell Programming and Scripting

Recycle Jboss server script

Hello, I need help writing a script to restart our Jboss server when it crashes. I am not very good with scripting but here is the basics. 1) I'm hoping to use KornShell 2) The command to stop the Jboss is "/var/opt/HP/ALM/jboss/bin/run.sh stop" 3) I want to verify the jboss is stopped before... (1 Reply)
Discussion started by: Blogger11
1 Replies

8. UNIX for Dummies Questions & Answers

Recycle bin on minix 3.2.1?

Hi. I'm started to use minix 3.2.1 recently and I'm trying to create a recycle bin for it. I'm kinda struggling on how to do it. I searched internet and I found scripts created for it but I actually didn't learn how to create scripts in college and I'm not sure if I understand them. I just wanted... (1 Reply)
Discussion started by: ReonarudoB
1 Replies

9. Shell Programming and Scripting

Recycle bin.

Hi. I've created scripts for a recycle bin that can list, restore and empty it. I only have the problem of deleting two files with the same name. When I do it one file overwrite the other. What could I do to resolve it? The only thing I can think is asking the user to rename file before moving to... (2 Replies)
Discussion started by: ReonarudoB
2 Replies
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 05:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy