04-25-2001
Try using a ? instead of the * The ? is for only one character place where as * is for multiple. I think this is will work in scripts also. (Haven't written any scripts yet)
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I write a sh script that zip and copy to tape all files that older then 2 hours.
1. The way I choose is - touch a file with "now - 2 hours", then use fine with '! -newer'
2. Do you have any other idea to do it ?
tnx. (1 Reply)
Discussion started by: yairon
1 Replies
2. UNIX for Dummies Questions & Answers
when ever i type it in it always looks like so
echo $file | sed 's/~/\
/g'
how can i get it on one line? (6 Replies)
Discussion started by: Optimus_P
6 Replies
3. UNIX for Dummies Questions & Answers
I am kind of new with Unix and I really need some help. Can you please tell me what the 'whatis' command is? and what does it do?
Let's say that I have a file which I want to delete, what command will I need to use?
If I have a directory that I want to delete all files from what command do... (11 Replies)
Discussion started by: mischiefdemon
11 Replies
4. UNIX for Dummies Questions & Answers
my solaris text talks about the 'find' command... it further goes to talk about an "action" used with the find command.
I am completely confused as to what the {} do with the find comand.
the explanation is this: "A set of braces, {}, delimits where the file name is passed to the command from... (2 Replies)
Discussion started by: xyyz
2 Replies
5. Shell Programming and Scripting
I wonder how I shall read the result below, especially 'what'
shown below.
The result was shown when I entered 'w'.
E.g what is TOP? What is gosh ( what does selmgr mean?)?
login@ idle JCPU PCPU what
6:15am 7:04 39 39 TOP
6:34am 6:45 45 45 TOP
6:41am ... (1 Reply)
Discussion started by: Aelgen
1 Replies
6. UNIX for Dummies Questions & Answers
Hi Gurus,
I would appreciate if someone could enlighten this newbie as to how significant the '&' is to unix.
Currently I am getting around to writing a script which has to deal with a lot of these ampersands either as starting chars or between chars.
Please find below the simpliest way that I... (4 Replies)
Discussion started by: buRst
4 Replies
7. Shell Programming and Scripting
I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong.
When I copy and paste it to the terminal, it is OK. Any idea what the problem might be?
set i = `grep -c #define flags.h`
while ($i>20)
@ i--
my func (`cat... (4 Replies)
Discussion started by: barisgultekin
4 Replies
8. UNIX for Dummies Questions & Answers
I apologize is this is somewhere else but I did look....
Is there a command to goto position # x within the VI editor? I've seen where you can search for a particular char string but I need to go to position 200 within a record (tired of counting positions)...:)
Thanks in advance... (2 Replies)
Discussion started by: hedrict
2 Replies
9. UNIX for Dummies Questions & Answers
Hi
I am having a 'grep' headache
Here is the contents of my file:
(PBZ,CP,(((ME,PBZ,BtM),ON),((ME,((PBZ,DG),(CW9,PG11))),CW9,TS2,RT1)))
I would like to count out how many times 'PBZ' occurs and then place that number in the line above
3... (8 Replies)
Discussion started by: cavanac2
8 Replies
10. Shell Programming and Scripting
I'm new using Unix commands in applescript. The following script you choose different folders with PDfs, get file count of PDfs on chosen folders, & write the results in text file.
set target_folder to choose folder with prompt "Choose target folders containing only PDFs to count files" with... (0 Replies)
Discussion started by: nellbern
0 Replies
LEARN ABOUT NETBSD
getopt
GETOPT(1) BSD General Commands Manual GETOPT(1)
NAME
getopt -- parse command options
SYNOPSIS
args=`getopt optstring $*`
set -- `getopt optstring $*`
DESCRIPTION
getopt is used to break up options in command lines for easy parsing by shell procedures, and to check for legal options. [Optstring] is a
string of recognized option letters (see getopt(3)); if a letter is followed by a colon, the option is expected to have an argument which may
or may not be separated from it by white space. The special option ``--'' is used to delimit the end of the options. getopt will place
``--'' in the arguments at the end of the options, or recognize it if used explicitly. The shell arguments ($1, $2, ...) are reset so that
each option is preceded by a ``-'' and in its own shell argument; each option argument is also in its own shell argument.
getopt should not be used in new scripts; use the shell builtin getopts instead.
EXAMPLES
The following code fragment shows how one might process the arguments for a command that can take the options [a] and [b], and the option
[c], which requires an argument.
args=`getopt abc: $*`
if [ $? -ne 0 ]; then
echo 'Usage: ...'
exit 2
fi
set -- $args
while [ $# -gt 0 ]; do
case "$1" in
-a|-b)
flag=$1
;;
-c)
carg=$2; shift
;;
--)
shift; break
;;
esac
shift
done
This code will accept any of the following as equivalent:
cmd -acarg file file
cmd -a -c arg file file
cmd -carg -a file file
cmd -a -carg -- file file
IEEE Std 1003.2 (``POSIX.2'') mandates that the sh(1) set command return the value of 0 for the exit status. Therefore, the exit status of
the getopt command is lost when getopt and the sh(1) set command are used on the same line. The example given is one way to detect errors
found by getopt.
DIAGNOSTICS
getopt prints an error message on the standard error output when it encounters an option letter not included in [optstring].
SEE ALSO
sh(1), getopt(3)
HISTORY
Written by Henry Spencer, working from a Bell Labs manual page. Behavior believed identical to the Bell version.
BUGS
Whatever getopt(3) has.
Arguments containing white space or embedded shell metacharacters generally will not survive intact; this looks easy to fix but isn't.
The error message for an invalid option is identified as coming from getopt rather than from the shell procedure containing the invocation of
getopt; this again is hard to fix.
The precise best way to use the set command to set the arguments without disrupting the value(s) of shell options varies from one shell ver-
sion to another.
BSD
November 28, 2009 BSD