Accepting command line arguments in bash


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Accepting command line arguments in bash
# 15  
Old 03-15-2012
Another option would be to switch to ksh93, a very advanced and fast shell, which fully supports floating point arithmetic.
# 16  
Old 03-15-2012
Quote:
Originally Posted by Scrutinizer
Another option would be to switch to ksh93, a very advanced and fast shell, which fully supports floating point arithmetic.
In there a conversion program from tcsh to ksh. I used csh2sh of Olivier Aubert to covert tcsh to sh code.

---------- Post updated at 07:27 PM ---------- Previous update was at 07:24 PM ----------

Quote:
Originally Posted by Scrutinizer
Another option would be to switch to ksh93, a very advanced and fast shell, which fully supports floating point arithmetic.
What do you think of zsh?
# 17  
Old 03-15-2012
You can just run that code with ksh93. It is also a Bourne shell derivative and is fully POSIX compliant. zsh has many interesting features but has a different syntax..

---------- Post updated at 01:52 ---------- Previous update was at 01:32 ----------

The important thing is on what platforms your scripts need to run, now and in the future. The safest best is to limit yourself to only the POSIX set of features. These scripts should run practically everywhere. Another route would be to use ksh93 and its more advanced features but it might not be available natively on every platform your script needs to run on, so that would mean you would need to install ksh93, which should not be a problem since it has become open source and there are packages for many platforms…

Last edited by Scrutinizer; 03-15-2012 at 09:58 PM..
# 18  
Old 03-16-2012
Notice that I did not do [ this && that ], but [ this ] && [ that ]

Instead of putting an && inside them, I made two logical statements joined with an && externally.

This is the same syntax you'd use to join external commands based on their return codes.

Code:
true && echo "The last command succeeded"
false || echo "The last command failed"

mangle_the_world || ( echo "Oh dear, mangling the world failed" ; putback_the_world )

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wanted: Help with escaping bash command line arguments

Please forgive me if this is the wrong forum. I want to execute some one liners with the groovy programming language and I'm having trouble escaping the special characters to accommodate bash. Here is one of the lines that is giving me trouble: groovy -e "(new... (1 Reply)
Discussion started by: siegfried
1 Replies

2. Shell Programming and Scripting

Passing arguments from a bash shell script to a command

I'm pretty new to bash scripting and I've found myself writing things like this (and the same with even more nesting): if $CATEGORIES; then if $LABEL_SLOTS; then $pyth "$wd/texify_grammar.py" "$input" "$texfile" "--label-slots" "--categories" "$CATEGORY_LIST" ... (9 Replies)
Discussion started by: burbly
9 Replies

3. Shell Programming and Scripting

command line arguments

hi,,,, I want to create a command prompt, for example "prompt>", so my prompt need to handle commands, for example "prompt>cmd", so i want to know how to get arguments for my own commands cmd, i.e. default argc should contain arguments count and argv should point to the argument vector i.e, for... (2 Replies)
Discussion started by: vins_89
2 Replies

4. Shell Programming and Scripting

Accepting user input and arguments in PERL

Hi All, Can we pass arguments while calling the perl script and as well as ask user input during execution of the script? My program is as below: I am passing arg1 and arg2 as argements to test.pl ]./test.pl arg1 arg2 Inside the test.pl I have : print "Do you want a name ? (y/n) : ";... (2 Replies)
Discussion started by: jisha
2 Replies

5. 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

6. Shell Programming and Scripting

Help parsing command line arguments in bash

Looking for a little help parsing some command line arguments in a bash script I am working on, this is probably fairly basic to most, but I do not have much experience with it. At the command line, when the script is run, I need to make sure the argument passed is a file, it exists in the... (3 Replies)
Discussion started by: Breakology
3 Replies

7. 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

8. Shell Programming and Scripting

Accepting filename as command line param and writing to it

Hi, Is it possible to accept a filename as command line parameter and then write to that file using command redirection? i tried the below script. outputfile=`echo $1` echo "Writing to file" > 'echo $outputfile' exit $returncode but it isnt working. is there any other way to... (9 Replies)
Discussion started by: silas.john
9 Replies

9. 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

10. Shell Programming and Scripting

Bash: Reading 2 arguments from a command line

If no arguments are entered I wanna be able to read 2 arguments, i have done like this but it doesnt work: x=0 until #loop starts do if ; then echo No arguments were entered, please enter 2 arguments. read $1 $2 elif || ; then echo $#... (0 Replies)
Discussion started by: Vozx
0 Replies
Login or Register to Ask a Question