Bash function accepting list of strings and error message


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash function accepting list of strings and error message
# 1  
Old 03-31-2012
Bash function accepting list of strings and error message

I have a variable strLst containing a list of strings. I want to create a function that takes the list and an error message. If the number of strings is 0 or greater than 1, I print the error message.
# 2  
Old 03-31-2012
Inside the function $# contains the number of arguments.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script accepting variables in valid number format

Hi Experts I would like to ask if there is a way to validate if the variable passed is in this kind of sample format "06-10" or "10-01". It was really a challenge to me on how to start and echnically the "6-10" stands for "June 10" and "10-01" stands as "October 1", overall it needs to have ... (3 Replies)
Discussion started by: ersan-poguita
3 Replies

2. Shell Programming and Scripting

Bash function to suppress warning message for specific text and display prompt

In the below bash function multiple variants are input and stored in a variable $variant, and each is written to an out file at c:/Users/cmccabe/Desktop/Python27/out.txt stored on a separate line. # enter variant phox2b() { printf "\n\n" printf "What is the id of the patient getting... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

sed garbled error message in bash shell

Sed garbled error. Cannot determine why the sed command to insert a line at the beginning of a file will not work on declared variables. outfile='DAR.V2.2012115.1.CSV' testfile='totality_request.sql' header_prefix='DATA FILE' no_ext_file=`echo $outfile |sed 's/\(.*\)..../\1/'` ... (6 Replies)
Discussion started by: smenago
6 Replies

4. Shell Programming and Scripting

Error Message in function causing failure.....

I have a long busybox ash script that has 3 stages. 1. Identify and Capture information on variable data sources, output the information to text file on each data source. 2. Using data from 1 above now actually do data processing on each individual dataset. 3. Produce report. So... (6 Replies)
Discussion started by: tesser
6 Replies

5. Shell Programming and Scripting

accepting images as a list and changing the name

Here is what I have so far #!/bin/bash while do read image jpegtopnm $image | pnmscale -height 200 | pnmtojpeg > $image-thumb echo $image-thumb shift done I sorta threw some pseudocode in there to demonstrate what I'm trying to do. . Where I am... (3 Replies)
Discussion started by: subway69
3 Replies

6. UNIX for Dummies Questions & Answers

Accepting command line arguments in bash

I have this tcsh code that I want to convert to a bash script. Basically it accepts command line arguments supplied by the user and stores them, so they can be used to run a C++ program. set arg_browseDir_inFileLst = "" set allArgsUpCase = `echo "$*" | tr '' ''` set opt_browseDir_flag =... (17 Replies)
Discussion started by: kristinu
17 Replies

7. Shell Programming and Scripting

How to list Matching Directories OR NULL w/o error message?

I want to be able to get all the directories in a path into a variable array, BUT if there ARE NO directories I want the Variable to be NULL and not echo any error message! If there ARE directories, this will get the list of the directories whose name begins with the string "20":... (6 Replies)
Discussion started by: pgorbas
6 Replies

8. Shell Programming and Scripting

BASH function error

Hey everyone. I am currently testing my first function based BASH script. The ultimate goal is going to be moving logs from point A to point B (or if B is down, to point C). Part of this involves the following function: function testAlive{ ping -c 1 -q $1 } Now when I run ping -c... (1 Reply)
Discussion started by: msarro
1 Replies

9. Shell Programming and Scripting

error when call function in bash script

Dear all, Could you please advice as I when call function i found the following error " refills: command not found" note that refills is function name. following also the function and how i call it function refills { echo "formatting refills and telepin" >> $log awk -F,... (20 Replies)
Discussion started by: ahmed.gad
20 Replies
Login or Register to Ask a Question