jus a minor issue. please assist if possible.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers jus a minor issue. please assist if possible.
# 1  
Old 03-17-2008
jus a minor issue. please assist if possible.

for an assignment i'm working on i have 2 minor issues with my code for the lines to be displayed after entering a line of code i.e:-

$ ls- l foo1.c
foo1.c not found

$ recycle
-rw-r--r-- 1 usr user 31 foo1.c
-rw-r--r-- 1 usr user 31 foo2.c

this is my working code .


******************************************
#!/bin/sh

if [ $# -eq 0 ]
then
echo "No recycling exist "
else


case "$1" in
-a)

if [ $# -gt 1 ] && [ -d recyclebin ]
then
echo "directory exist"
mv /home/assignment2/$2 /home/assignment2/recyclebin
else

echo ".recyclebin does not exist "
echo "Creating the .recyclebin directory and adding the file now."
mkdir /home/assignment2/recyclebin
mv /home/assignment2/$2 /home/assignment2/recyclebin
fi
;;

-e)
rm -rf /home/assignment2/recyclebin
echo "The recyclebin is empty "
;;


-h)
echo "-a adds a file for recycling. If this -a option is used and"
echo " no .recyclebin directory, recycle notifies the user, and"
echo " creates the directory and moves the file to .recyclebin"
echo " "
echo "-e removes all files from .recyclebin and prints a message saying"
echo " that the recycle bin is empty."
;;
esac
fi
**************************************************

i'm thinking that for this option "$ recycle ", i would need to check that the number of paramaters is equal to zero ( if [ $# -eq 0 ] ) and also the number of elements in the recyclebin folder is greater than 0. could you explain to me how i could go about doing that part.



also ls -l would list the files in the specific directory and their permissions.
how do i show that the file was not found i.e:
$ ls- l foo1.c
foo1.c not found
# 2  
Old 03-17-2008
"how do i show that the file was not found"



Since this could be a homework assignment, I don't want to give you the answer, but try reading about some options to the grep or ls commands

man grep

man ls
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Minor changes to script

isNumeric() { numericExpression='^+$' if ! ] then echo 1; else echo 0; fi } getColumnData() { echo `echo $1|cut -d "," -f1,2 --output-delimiter " "` } containsSegment() { if ] || ] || ] ... (2 Replies)
Discussion started by: ramyags
2 Replies

2. Shell Programming and Scripting

Minor Calculation Error

Hello everyone!! I got a slight problem doing some calculation from the text file. I able to get the specific data by cutting it using grep and cut. The amount can be calculated but the problem I faced now is even the field which I didnt cut is been calculated too. This is what I meant. The... (2 Replies)
Discussion started by: aLHaNz
2 Replies

3. Shell Programming and Scripting

In need of assist....

How would i take the output of a file dump it into another file while at the same time sorting it? this is my script..simple i know!? echo "Enter the file log you wish to use. : " read file awk '{print $1,$2,$4,$5}' $file >> list Im trying to dump it into that list file and sort it at... (6 Replies)
Discussion started by: jspinal
6 Replies

4. UNIX for Dummies Questions & Answers

Please Assist

I try taip this script below...but i have got error.The error message is Input read error..Anybody can see whether my script have problem.Below this is my script: #!/bin/sh filename=test.txt vi $filename <<EndOfCommands i This file was created automatically from a shell script ^ (1 Reply)
Discussion started by: mastercar
1 Replies

5. HP-UX

Assist me in doing certification please

Hi Everybody, Iam new to the unix world but interested a lot to know about unix. i want to do a certification course in unix so can anybody please suggest me what course can i do for unix adminstration and what books do i have to refer to. Thanks in Advance. (5 Replies)
Discussion started by: ajazshariff
5 Replies

6. UNIX for Dummies Questions & Answers

Script Assist

Hello all I am new and I had a question that I was hoping you could answer. I am using mutt on a directory in this directory will be pdf files named 001.pdf , 002.pdf and so on. I need a script that can read the filename and associate that with a user like so : if 001.pdf exists then email... (16 Replies)
Discussion started by: linuxguy30350
16 Replies

7. HP-UX

Time Modified Issue Please Assist

I am trying to periodically check that the environment variables have not been changed on a HP-UX server. This was going to be easy except I ran into the odd circumstance of having two files that should be created equally be created differently when one is created by command line and the other is... (1 Reply)
Discussion started by: Emancipator
1 Replies

8. Post Here to Contact Site Administrators and Moderators

minor issue on question that i had posted !!

to the moderators of this site... i posted a question several weeks ago about a egep -e if you look through my posts you will see that my question was fully plausible as a reasonable post that could have been answered even it was to say that I should search the man pages myself and find the... (4 Replies)
Discussion started by: moxxx68
4 Replies

9. Programming

could some assist please

i was searching on the net have found a couple of sample programs and was wondering if some could tell me what they do cheers. main() { printf("Executing ls\n"); execl("/bin/ls","ls","-l", (char *)0); perror("execl failed to run ls"); exit(1); } main() { int i; i =... (5 Replies)
Discussion started by: ruffenator
5 Replies
Login or Register to Ask a Question