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:
check if one argument is given, if anything other than one argument was passed an error message should be printed.
check if the "~/.saferm" directory exists using an "if" statement. If it doesn't, create it.
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
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)
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)
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)
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)
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)
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)
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)
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
LEARN ABOUT HPUX
mkdir
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)