Sponsored Content
Full Discussion: script similar to rm utility
Homework and Emergencies Homework & Coursework Questions script similar to rm utility Post 302475727 by Joey12 on Monday 29th of November 2010 05:42:11 PM
Old 11-29-2010
script similar to rm utility

1. The problem statement, all variables and given/known data:

saferm is a replacement for the rm utility. Rather than removing files, it move files in a sub directoy called".saferm" in the user's home directory. If "~/.saferm" doesn't exist, it is automatically created. The -l options lists the current contents of the "~/.saferm" directory.

Only the -l option or a valid existing filename can be specified at one time. Print a suitable error message and terminate the script otherwise.


2. Relevant commands, code, scripts, algorithms:
  1. check if one argument is given, if anything other than one argument was passed an error message should be printed.
  2. check if the "~/.saferm" directory exists using an "if" statement. If it doesn't, create it.
  3. In the third part, check if "-l" was passed using an"if" statement, If it was, then display the files in the "~/.saferm" directory. If not, then move the file to the "~/.saferm" directory.



3. The attempts at a solution (include all code and scripts):
Code:
if [ $# != 1 ]
   then
      echo "Usage: saferm  -l  (or a filename)" >&2
      exit 1
fi



if[! -d ~/.saferm]
   then
       mkdir ~/.saferm
fi

if["$1-l"]
then
    ls -l ~/.saferm
fi



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

George Brown,Toronto,Canada,George Sayegh,COMP1156
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cdrdao utility script

friends, i love ya... i wrote a script to automate using cdrdao to burn an audio cd from mp3 files, using the great tutorial at http://tldp.org/HOWTO/MP3-CD-Burning/index.html (check out the site, i believe that it's very well-written). i messed around with it and got to a place where i felt... (2 Replies)
Discussion started by: snwright
2 Replies

2. Shell Programming and Scripting

sort utility in script ?

Hi friends, I want to use sort command in script. I used the following syntax in my scipt, sort -t '|' +3 tempcdrext4.cdr > temp.mocdr It give me a error " Input file specified two times." but this command work fine in the prompt without any problem. Can sombody please tell me who... (2 Replies)
Discussion started by: maheshsri
2 Replies

3. UNIX for Dummies Questions & Answers

Need help on SCRIPT(1M) utility

Hi All, I need to do a lot of manual entries at shell prompt. So to collect the logs(each command fired in that session, i use "SCRIPT(1) : make typescript of terminal session" this is kool,but the problem here is that it saves the linefeed, and backspaces along with the commands in the log... (1 Reply)
Discussion started by: amit4g
1 Replies

4. Shell Programming and Scripting

copy similar files only both at different locations using script.

Hello, Here is the situation.............. # pwd /opt/123 # cat index.txt abc-monitor/homedir/public_html/index.php abc-monitor/homedir/public_html/test/index.php abc-monitor/homedir/public_html/test1/index.php # cp index.txt index.home # cat /root/x (1 Reply)
Discussion started by: fed.linuxgossip
1 Replies

5. Shell Programming and Scripting

Help on how to call a utility from script

Hi, I am new to shell scripting (sh) I need a script which will call a utility & once u call it.It will ask for inputs on the screen.These inputs it needs to get or read from a txt file. for e.g #! /bin/sh while read line do echo $line done txt file will have test 01/01/2008 ... (3 Replies)
Discussion started by: innocent
3 Replies

6. Shell Programming and Scripting

Writing a Utility Script

Hi All ,, I have couple of shell scripts .. I am trying to build a Utility script which would call each script example :: ======== 1) uni.sh 2) uni2.sh 3)uni3.sh when i run the Util script it will come as a menu ,, once i press 1 it will call the first shell script and runs it ..... (10 Replies)
Discussion started by: raghav1982
10 Replies

7. Shell Programming and Scripting

I need help to run this utility from a shell script

I need some help to run this executable from within a shell script. The Script is run the following way at the command prompt. $rateupd Main Menu --Standard Output ----------- --Standard Output 1. - Update Rate --Standard Output 2. - Exit. --Standard Output Enter Selection: 1 --User... (5 Replies)
Discussion started by: rajeeb_d
5 Replies

8. Shell Programming and Scripting

shell script similar to the command HEAD

hello please if anyone can help me make a shell script similar to the command HEAD and TAIL THANKS (3 Replies)
Discussion started by: BELLA86
3 Replies

9. Shell Programming and Scripting

Shell script matching similar records

hello all, I have requirement to identify similar records matching about 80% to 90%.I have to black list customers with multiple accounts. The data is in the Oracle Database, but is there any way I can get the data into flat file and compare the strings and fetch similar matching records? ... (2 Replies)
Discussion started by: kashik786
2 Replies

10. Shell Programming and Scripting

Isolate text with sed or similar utility

All, I'm getting a list like the following and I'd like to kill each PID in turn. pid (17797) pid (21748) pid (21754) pid (21704) pid (2199) pid (2159) pid (17809) pid (21769) pid (21778) pid (21715) ... (3 Replies)
Discussion started by: ejianu
3 Replies
mkdir(1)						      General Commands Manual							  mkdir(1)

NAME
mkdir - make a directory SYNOPSIS
mode] dirname ... DESCRIPTION
creates specified directories in mode 0777 (possibly altered by unless specified otherwise by a option (see umask(1)). Standard entries, (for the directory itself) and (for its parent) are created automatically. If dirname already exists, exits with a diagnostic message, and the directory is not changed. Options recognizes the following command-line options: After creating the directory as specified, the file permissions are set to mode, which is a symbolic mode string as defined for (see chmod(1)). The has precedence over Intermediate directories are created as necessary. Otherwise, the full path prefix of dirname must already exist. requires write permission in the parent directory. For each directory name in the pathname prefix of the dirname argument that is not the name of an existing directory, the specified directory is created using the current setting, except that the equivalent of is done on each component to ensure that can create lower directories regardless of the setting of Each directory name in the pathname prefix of the dirname argument that matches an existing directory is ignored without error. If an intermediate path component exists, but has permissions set to prevent writing or searching, fails with an error message. If the option is used, the directory specified by dirname (excluding directories in the pathname prefix) is created with the permissions specified by mode. Only subdirectories can be created (see limits(5)). Access Control Lists - JFS File Systems Only If the parent directory has an access control list (ACL, see aclv(5)), and that ACL contains default entries, an ACL is created for the new directory, and the parent directory's default entries are applied to the new directory's ACL, both as regular entries and as default entries. EXTERNAL INFLUENCES
For information about the UNIX standard environment, see standards(5). Environment Variables provides a default value for the internationalization variables that are unset or null. If is unset or null, the default value of "C" (see lang(5)) is used. If any of the internationalization variables contains an invalid setting, will behave as if all internationalization variables are set to See environ(5). If set to a non-empty string value, overrides the values of all the other internationalization variables. determines the interpretation of text as single and/or multi-byte characters, the classification of characters as printable, and the char- acters matched by character class expressions in regular expressions. determines the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informa- tive messages written to standard output. determines the location of message catalogues for the processing of International Code Set Support Single- and multi-byte character code sets are supported. DIAGNOSTICS
returns exit code 0 if all directories were created successfully. Otherwise, it prints a diagnostic and returns non-zero. returns exit code 0 if the option was specified, and all the specified directories now exist. If any of the intermediate directories do not have search or write permission (with the option), prints a diagnostic and returns non-zero. EXAMPLES
Create directory beneath existing directory in the current directory: Create directory path underneath the current directory and set permissions on directory to read-only for all users which is equivalent to (see chmod(1)): If directories or and already exist, only the missing directories in the specified path are created. SEE ALSO
rm(1), setacl(1), sh(1), umask(1), aclv(5), standards(5). STANDARDS CONFORMANCE
mkdir(1)
All times are GMT -4. The time now is 06:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy