Sponsored Content
Top Forums Shell Programming and Scripting intro to UNIX - making a sort-of recycle bin (for fun) Post 302310754 by jzacsh on Monday 27th of April 2009 12:18:37 AM
Old 04-27-2009
Bug 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

Code:
# if files exist, remove contents (of purge directory)
ls -lA ~/purge;
echo "^ this was a test, to be sure the following command should work"

purgeTest= "ls -lA ~/purge" # setting a variable to check contents of ~/purge
if [ $purgeTest -ne "total 0" ]; then
rm -r ~/purge/* 
fi

side note: I would think that checking if a directory (line 5) has contents is unnecessary, except when I just had rm -r ~/purge/* written, I'd get rm: cannot remove `/home/jzacsh/purge/*': No such file or directory BUT only when the purge directory was empty.

Here is the output I'm seeing on login:
Code:
total 0
^ this was a test, to be sure the following command should work
bash: ls -lA ~/purge: No such file or directory
bash: [: -ne: unary operator expected
jzacsh@dell8300:~$

bottom line, questions:
what am i doing wrong to get the "no such file or directory" error, in line 3 just above? (am I using variables incorrectly?)

is -ne operator only for mathematic comparisons - line 4 of error? if so, what should I use?

-thanks in advance for any suggestions!
 

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

Recycle Bin Script

Hello, I have having problems with an assignment and am pretty desperate. My assignment is to create a shell script that does a Recycle_Bin tasks. You can only open this with PuTTY software or Knoppix. Perhaps on other software that are able to read linux language. My part is stuck... (2 Replies)
Discussion started by: chueu
2 Replies

3. What is on Your Mind?

Indians making fun of Indians in a new TATA ad

This is a nice ad by Tata.... a2lPniSsFxs (1 Reply)
Discussion started by: Neo
1 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. UNIX for Dummies Questions & Answers

UNIX fun stuff - echo and dc - obfuscate/garble a string sort of

Hi, Humorous UNIX Commands shows a fun way of using echo and dc to sort of obfuscate a string. % echo 'sasb3135071790101768542287578439snlbxq'|dc GET A LIFE! I am just wanting to know if there is a way to sort of use dc and echo to print out an obfuscated/garbled string instead... (3 Replies)
Discussion started by: newbie_01
3 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
BACKUP-MANAGER-PURGE(8) 				       backup-manager-purge					   BACKUP-MANAGER-PURGE(8)

NAME
backup-manager-purge - backup-manager's wrapper for outdating files SYNOPSIS
backup-manager-purge [TTL] <options> DESCRIPTION
backup-manager-purge is the only authorized entity that can say if an archive should be purged or not. Any tasks used by backup-manager may have to know if an archive is deprecated (eg: the purging phase of an upload method). This tool is here to fulfill that need. Given a time to live (TTL) and a list of archives, backup-manager-purge will return another list of archives, corresponding to the ones that are outdated by the TTL. REQUIRED ARGS
--ttl=time-to-live Specify the time to live (in days) for the archives. Any archive that is older than ttl days will be outdated. OPTIONAL ARGS
--files-from=file A file containing a list of archives to parse, one archive per line. If this option is not used, STDIN will be used for catching the files to parse. RETURN
backup-manager-purge will return the list of outdated files on STDOUT, one file per line. ERROR CODES
If an error occurs, it will print the error message on stderr and will exit with an error code greater than 0. Here are the possible error codes: bad command line (wrong arguments) : 10 internal error (should be reported as a bug) : 20 SEE ALSO
backup-manager(8) backup-manager-upload(8) AUTHORS
Concept and design by Alexis Sukrieh and Jan Metzger. perl v5.14.2 2012-05-09 BACKUP-MANAGER-PURGE(8)
All times are GMT -4. The time now is 02:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy