Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Bash condition test at the end of string Post 302902350 by Don Cragun on Tuesday 20th of May 2014 06:01:12 AM
Old 05-20-2014
Your question doesn't make any sense.
If statements don't read data from pipes.
You have shown us four echo statements (each of which prints at least three consecutive spaces piped into if statements with comments saying two of them don't contain three spaces???
Then you have shown us a conditional expression that performs two pathname expansions and performs logical and and not operations on those expansions in ways that might or might not be syntax errors depending on what files exist in the current directory.

If you want to write a function, the first thing you need to do is clearly explain what input that function is going to receive and what output it is supposed to produce.
This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

test and if condition

Guys look at this: i have to write a script that takes a file as an argument. The script should be able to determine what permissions the owner, group and everybody has for the file passed in. The output should be displayed similar to this. READ WRITE EXECUTE OWNER LEE.BALLANCORE YES YES NO... (9 Replies)
Discussion started by: ciroredz
9 Replies

2. UNIX for Dummies Questions & Answers

Condition test

Hi there, When I try to do a condition on test: $ str1=abcd $ test $str1 $ echo $? 0 Is there anyway to display the answer to be 'TRUE' or 'YES'? rather than 0? If so, how can I do it without using awk or sed. (2 Replies)
Discussion started by: felixwhoals
2 Replies

3. Shell Programming and Scripting

Test condition

Hello, what is the better and correct way to perform a comparison: I have been using the following with no problems: if ] then .... fi I have seen this also used : if then .... fi When I try : if then .... fi I get an error like .... the test condition expects a... (4 Replies)
Discussion started by: gio001
4 Replies

4. Shell Programming and Scripting

test condition

Hi there, I tried to search for this almost everywhere, but didnt get any proper information on it. What is the difference between ] Some of the code works when I have only single condition i.e. ] && $dothis1 || $dothis2 But if i try to include another testcondition to the... (1 Reply)
Discussion started by: tostay2003
1 Replies

5. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

6. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

7. Shell Programming and Scripting

Test of more than one number on the end of a string

Hi there, I have a bunch of interface names like e1000g0 nge1 dmfe3 I also have some that have longer (vlan tagged) names like e1000g123001 nge23003 e1000g999002 I need to determine whether the interface is one of the former or latter types and I would do that by seeing... (7 Replies)
Discussion started by: rethink
7 Replies

8. Shell Programming and Scripting

BASH: remove digits from end of string

Hi there, im sure this is really simple but i have some strings like this e1000g123001 e1000g0 nge11101 nge3and i want to create two variables ($DRIVER and $INSTANCE). the first one containing the alpha characters that make up the first part of the string, e.g. e1000g or nge and the... (9 Replies)
Discussion started by: rethink
9 Replies

9. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

10. Solaris

Test program running taking much more time on high end server T5440 than low end server T5220

Hi all, I have written the following program and run on both T5440 and T5220 on same OS version. I found that T5540 server takes more time than T5220. Please find below the details. test1.cpp #include <iostream> #include <pthread.h> using namespace std; #define NUM_OF_THREADS 20... (17 Replies)
Discussion started by: sanjay_singh85
17 Replies
BAS(1)							      General Commands Manual							    BAS(1)

NAME
bas - basic SYNOPSIS
bas [ file ] DESCRIPTION
Bas is a dialect of Basic. If a file argument is provided, the file is used for input before the terminal is read. Bas accepts lines of the form: statement integer statement Integer numbered statements (known as internal statements) are stored for later execution. They are stored in sorted ascending order. Non-numbered statements are immediately executed. The result of an immediate expression statement (that does not have `=' as its highest operator) is printed. Interrupts suspend computation. Statements have the following syntax: expression The expression is executed for its side effects (assignment or function call) or for printing as described above. comment This statement is ignored. It is used to interject commentary in a program. done Return to system level. dump The name and current value of every variable is printed. edit The UNIX editor, ed, is invoked with the file argument. After the editor exits, this file is recompiled. for name = expression expression statement for name = expression expression next The for statement repetitively executes a statement (first form) or a group of statements (second form) under control of a named vari- able. The variable takes on the value of the first expression, then is incremented by one on each loop, not to exceed the value of the second expression. goto expression The expression is evaluated, truncated to an integer and execution goes to the corresponding integer numbered statment. If executed from immediate mode, the internal statements are compiled first. if expression statement if expression [ else fi The statement (first form) or group of statements (second form) is executed if the expression evaluates to non-zero. In the second form, an optional else allows for a group of statements to be executed when the first group is not. list [expression [expression]] is used to print out the stored internal statements. If no arguments are given, all internal statements are printed. If one argument is given, only that internal statement is listed. If two arguments are given, all internal statements inclusively between the argu- ments are printed. print list The list of expressions and strings are concatenated and printed. (A string is delimited by " characters.) prompt list Prompt is the same as print except that no newline character is printed. return [expression] The expression is evaluated and the result is passed back as the value of a function call. If no expression is given, zero is returned. run The internal statements are compiled. The symbol table is re-initialized. The random number generator is reset. Control is passed to the lowest numbered internal statement. save [expression [expression]] Save is like list except that the output is written on the file argument. If no argument is given on the command, b.out is used. Expressions have the following syntax: name A name is used to specify a variable. Names are composed of a letter followed by letters and digits. The first four characters of a name are significant. number A number is used to represent a constant value. A number is written in Fortran style, and contains digits, an optional decimal point, and possibly a scale factor consisting of an e followed by a possibly signed exponent. ( expression ) Parentheses are used to alter normal order of evaluation. _ expression The result is the negation of the expression. expression operator expression Common functions of two arguments are abbreviated by the two arguments separated by an operator denoting the function. A complete list of operators is given below. expression ( [expression [ , expression] ... ] ) Functions of an arbitrary number of arguments can be called by an expression followed by the arguments in parentheses separated by commas. The expression evaluates to the line number of the entry of the function in the internally stored statements. This causes the internal statements to be compiled. If the expression evaluates negative, a builtin function is called. The list of builtin functions appears below. name [ expression [ , expression ] ... ] Each expression is truncated to an integer and used as a specifier for the name. The result is syntactically identical to a name. a[1,2] is the same as a[1][2]. The truncated expressions are restricted to values between 0 and 32767. The following is the list of operators: = = is the assignment operator. The left operand must be a name or an array element. The result is the right operand. Assignment binds right to left, & | & (logical and) has result zero if either of its arguments are zero. It has result one if both its arguments are non-zero. | (log- ical or) has result zero if both of its arguments are zero. It has result one if either of its arguments are non-zero. < <= > >= == <> The relational operators (< less than, <= less than or equal, > greater than, >= greater than or equal, == equal to, <> not equal to) return one if their arguments are in the specified relation. They return zero otherwise. Relational operators at the same level extend as follows: a>b>c is the same as a>b&b>c. + - Add and subtract. * / Multiply and divide. ^ Exponentiation. The following is a list of builtin functions: arg(i) is the value of the i -th actual parameter on the current level of function call. exp(x) is the exponential function of x. log(x) is the natural logarithm of x. sqr(x) is the square root of x. sin(x) is the sine of x (radians). cos(x) is the cosine of x (radians). atn(x) is the arctangent of x. Its value is between -n/2 and n/2. rnd( ) is a uniformly distributed random number between zero and one. expr( ) is the only form of program input. A line is read from the input and evaluated as an expression. The resultant value is returned. abs(x) is the absolute value of x. int(x) returns x truncated (towards 0) to an integer. FILES
/tmp/btm? temporary b.out save file /bin/ed for edit DIAGNOSTICS
Syntax errors cause the incorrect line to be typed with an underscore where the parse failed. All other diagnostics are self explanatory. BUGS
Has been known to give core images. Catches interrupts even when they are turned off. BAS(1)
All times are GMT -4. The time now is 11:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy