Sponsored Content
Full Discussion: Filter command arguments
Homework and Emergencies Homework & Coursework Questions Filter command arguments Post 302661681 by bakunin on Monday 25th of June 2012 03:06:55 PM
Old 06-25-2012
Congrats! You are almost there and you lack only small things.

Here are some pointers:

1. You haven't said anything about the shell you are using but somehow i doubt you are using a Bourne shell. More likely "/bin/sh" is a POSIX shell, a bash (Bourne Again Shell) or a ksh (Korn Shell). All these shells have an arithmetic facility and while what you do is syntactically correct using "expr" like you do is ancient, antiquated, deprecated and ultimately discouraged. See the "(( ... ))" in the man page of your shell and you will understand why.

2. The same goes for backticks: modern shells understand these only for purposes of backwards compatibility and using them has no advantages but a lot of disadvantages. Have a look in the man page for "$( ... )" as a device to execute a command in a subshell.

3. Your handling of the "num" variable: All usual shells allow variables to be used without having to declare them (unlike languages like C or PASCAL), but it is still good style to declare properly what you use prior to using it. Again, what you do is syntactically correct, but .... Using a line like

Code:
typeset -i num=0              # buffer to loop through arguments
typeset -i total=0            # buffer to sum up results

at the start of the script allows you to: give the variables a proper type, a sensible starting value and - even more important - to document their usage. If you look later at your code you will immediately know what you did by simply reading the comments.

OK, lets talk about this, then go on as you correct these errors. I will expand on this later.

I hope this helps.

bakunin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

GREP Command with several arguments

Hi! $ more file yoyo haha lili ... i want to test if a "grep yoyo AND lili" works in this file. In fact, my script will carry on only if it finds in the same line "yoyo" AND "lili" How can i do? Thx! (3 Replies)
Discussion started by: tomapam
3 Replies

2. UNIX for Dummies Questions & Answers

arguments in command line

Hi all, How many arguments can we pass while testing a prgm at command line.. I encountered an issue while passing 10 arguments. For $10 its taking argument passed for $1 followed by 'zero'. can we pass more than 9 arguments /Is there any other way. Thanks, rrs (6 Replies)
Discussion started by: rrs
6 Replies

3. HP-UX

get whole command arguments in ps -ef?

Hello All, I want to build some monitoring of processes in HP-UX 11.x. Is there any way to get the whole set of commands and arguments instead of the first 60 characters? I read that there's a limitation of the ps -ef command that we can't overcome. In this case is there any other command... (17 Replies)
Discussion started by: usfrog
17 Replies

4. Shell Programming and Scripting

how to filter `last` command for yesterday only

Hi Expert, May I know how to filter `last` command out put for yesterday only ? my `last` command out put: user1 pts/3 192.168.0.12 Wed Jun 25 03:58 still logged in user1 pts/3 192.168.0.33 Wed Jun 23 02:08 - 09:58 (00:49) user2 pts/1 192.168.0.21 ... (1 Reply)
Discussion started by: skully
1 Replies

5. UNIX for Dummies Questions & Answers

Command line arguments.

I am working on a script wherein i need the user to enter the Build ID for eg:the command line will show enter the build ID Now on entering the build ID it should be assigned to @ARGV. How can this be done.? (1 Reply)
Discussion started by: Varghese
1 Replies

6. Shell Programming and Scripting

filter grep command

I have ran into a small issue and I am not sure how to fix it. In one of our current scripts we have this line which does a grep to get the pid of the process. ps -ef | grep nco_p_syslog | grep $x | awk '{print $2}' However this is not returning anything due to the how long the value... (7 Replies)
Discussion started by: LRoberts
7 Replies

7. UNIX for Dummies Questions & Answers

command line arguments

hi, can someone how to accept command line arguments as a variable using in script? like: ./scriptname arguments by accept arguments, I can use it in my script? thx! (1 Reply)
Discussion started by: ikeQ
1 Replies

8. Homework & Coursework Questions

Using tail with the filter command

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: Devise a chain of filters using some or all of the following programs pr, cut, cat, tail to display a numbered... (8 Replies)
Discussion started by: hbell221
8 Replies

9. Shell Programming and Scripting

Use of awk to filter out the command output

Hi All, I am trying to find out number of cores present for hp-ux server from the output of print_manifest (as shown below). i suppose awk will be best tool to use for filtering. output of print_manifest is : System Hardware Model: ia64 hp Integrity Virtual Partition ... (6 Replies)
Discussion started by: omkar.jadhav
6 Replies

10. Shell Programming and Scripting

Filter pattern in grep command

Hi, I am having a file like below hello how are you hello... (5 Replies)
Discussion started by: rohit_shinez
5 Replies
DROP TEXT SEARCH 
TEMPLATE(7) PostgreSQL 9.2.7 Documentation DROP TEXT SEARCH TEMPLATE(7) NAME
DROP_TEXT_SEARCH_TEMPLATE - remove a text search template SYNOPSIS
DROP TEXT SEARCH TEMPLATE [ IF EXISTS ] name [ CASCADE | RESTRICT ] DESCRIPTION
DROP TEXT SEARCH TEMPLATE drops an existing text search template. You must be a superuser to use this command. PARAMETERS
IF EXISTS Do not throw an error if the text search template does not exist. A notice is issued in this case. name The name (optionally schema-qualified) of an existing text search template. CASCADE Automatically drop objects that depend on the text search template. RESTRICT Refuse to drop the text search template if any objects depend on it. This is the default. EXAMPLES
Remove the text search template thesaurus: DROP TEXT SEARCH TEMPLATE thesaurus; This command will not succeed if there are any existing text search dictionaries that use the template. Add CASCADE to drop such dictionaries along with the template. COMPATIBILITY
There is no DROP TEXT SEARCH TEMPLATE statement in the SQL standard. SEE ALSO
ALTER TEXT SEARCH TEMPLATE (ALTER_TEXT_SEARCH_TEMPLATE(7)), CREATE TEXT SEARCH TEMPLATE (CREATE_TEXT_SEARCH_TEMPLATE(7)) PostgreSQL 9.2.7 2014-02-17 DROP TEXT SEARCH TEMPLATE(7)
All times are GMT -4. The time now is 03:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy