Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Simple negated test condition Post 302949918 by sea on Friday 17th of July 2015 01:34:58 PM
Old 07-17-2015
Does this work?
(bash)
Code:
[ -z "${var/car}" ] && echo yes || echo no

EDIT: n/m too hot to think clear, figured after re-reading.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need help with test condition in shell script

I'm new to scripting and I need help with a bourn shell script. What i'm trying to do is a test condition where "if the time is within 2 hours, it's true" and so on. The time is in the following format DATE=`/bin/date +"%Y%m%d%H%S"` for example, 20060907152000. So, what the script first... (9 Replies)
Discussion started by: pieman8080
9 Replies

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

3. Shell Programming and Scripting

Condition test ( [[ ]] ) doubt

Hi , I have a doubt on condition test ( ] ). Pls refer blow program. #!/bin/ksh TEMP= if ;then echo $TEMP else print 'invalid option' fi Above script's TEMP variable has no value so it gives "invalid option" as output. But I got an error before priting the string . Result : ... (2 Replies)
Discussion started by: thambi
2 Replies

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

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

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

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

8. UNIX for Advanced & Expert Users

Condition to test if a host can be pinged

I have a much larger script that takes an input file of hosts and determines if we support them and checks to ensure the FQDN coincides with our DNS. For instance, the hostname may return a different FQDN when passed to the "host" command, so I keep the value of the output of the "host" command... (4 Replies)
Discussion started by: MaindotC
4 Replies

9. UNIX for Advanced & Expert Users

Lower case test condition

I want to locate directories that are upper, lower or have both upper and lower cases. What I have is: find /tmp/$var2 -type d' " ); && echo "host case is incorrect" || echo "host case is correct" This actually is part of a larger script and it does work but the problem is that it... (3 Replies)
Discussion started by: newbie2010
3 Replies

10. UNIX for Beginners Questions & Answers

Test a condition for n times and take action

i have to test a condition for n times and if its value is greater than one each time for continuous 5 iterations it will take action My Approach run the same command 5 times in for loop and divert the output to a file and then read the values from file and use if else if and take action ... (1 Reply)
Discussion started by: abhaydas
1 Replies
Highlight(3pm)						User Contributed Perl Documentation					    Highlight(3pm)

NAME
HTML::Highlight - A module to highlight words or patterns in HTML documents SYNOPSIS
use HTML::Highlight; # create the highlighter object my $hl = new HTML::Highlight ( words => [ 'word', 'any', 'car', 'some phrase' ], wildcards => [ undef, '%', '*', undef ], colors => [ '#FF0000', 'red', 'green', 'rgb(255, 0, 0)' ], czech_language => 0, debug => 0 ); # Remember that you don't need to specify your own colors. # The default colors should be optimal. # Now you can use the object to highlight patterns in a document # by passing content of the document to its highlight() method. # The highlighter object "remembers" its configuration. my $highlighted_document = $hl->highlight($document); MOTIVATION
This module was originaly created to work together with fulltext indexing module DBIx::TextIndex to highlight search results. A need for a highlighter that takes wildcard matches and HTML tags into account and supports czech language (or other Slavic languages) was the motivation to create this module. DESCRIPTION
This module provides Google-like highlighting of words or patterns in HTML documents. This feature is typically used to highlight search results. The construcutor: my $hl = new HTML::Highlight ( words => [], wildcards => [], colors => [], czech_language => 0, debug => 0 ); This is a constructor of the highlighter object. It takes an array of even number of parameters. The words parameter is a reference to an array of words to highlight. The wildcards parameter is a reference to an array of wildcards, that are applied to corresponding words in the words array. A wildcard can be either undef or one of '%' or '*'. The "%" character means "match any characters": "%" applied to 'car' ==> matches "car", "cars", "careful", ... The "*" character means "match also plural form of the word": "*" applied to 'car' ==> matches only "car" or "cars" An undefined wildcard means "match exactly the corresponding word": undefined wildcard applied to 'car' ==> matches only "car" The colors parameter is a reference to an array of CSS color identificators, that are used to highlight the corresponding words in the words array. Default Google-like colors are used if you don't specify your own colors. Number of colors can be lower than number of words - in this case the colors are rotated and some of the words are therefore highlighted using the same color. The highlighter takes HTML tags into account and therefore does not "highlight" a word or a pattern inside a tag. A support for diacritics insenstive matching for ISO-8859-2 languages (for for example the czech language) can be activated using the czech_language option. This feature requires a module CzFast that is available on CPAN in a directory of author TRIPIE or at http://geocities.com/tripiecz/. Your system's locales must be set correctly to use the czech_language feature. highlight my $hl_document = $hl->highlight($document); The only parameter is a document in that you want to highlight the words that were passed to the constructor of the highlighter object. The method returns a version of the document in which the words are highlighted. preview_context my $sections = $hl->preview_context($document, $num); This method takes two parameters. The first one is the document you want to scan for the words that were passed to the constructor of the highlighter object. The second parameter is an optional integer that specifies maximum number of characters in each of the context sections (see below). This parameter defaults to 80 characters if it's not specified. Minimum allowed value of this parameter is 60. The method returns a reference to an array of sections of the document in which the words that were passed to the constructor appear. HTML tags are removed before the document is proccessed and are not present in the ouput. This feature is typically used in search engines to preview a context in which words from a search query appear in the resulting documents. The words are always in the middle of each of the sections. The number of sections this method returns is equal to the number of words passed to the constructor of the highlighter object. That means only the first occurence of each of the words is taken into account. SUPPORT
No official support is provided, but I welcome any comments, patches and suggestions on my email. BUGS
I am aware of no bugs. AVAILABILITY
http://geocities.com/tripiecz/ AUTHOR
Tomas Styblo, tripie@cpan.org, CPAN-ID TRIPIE Prague, the Czech republic LICENSE
HTML::Highlight - A module to highlight words or patterns in HTML documents Copyright (C) 2000 Tomas Styblo (tripie@cpan.org) This module is free software; you can redistribute it and/or modify it under the terms of either: a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" which comes with this module. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the Artistic License for more details. You should have received a copy of the Artistic License with this module, in the file Artistic. If not, I'll be glad to provide one. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA SEE ALSO
perl(1). perl v5.10.0 2009-06-04 Highlight(3pm)
All times are GMT -4. The time now is 06:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy