Sponsored Content
Top Forums Shell Programming and Scripting if condition for variable existing in file Post 302287851 by eltinator on Sunday 15th of February 2009 11:28:08 PM
Old 02-16-2009
Thanks for the quick response but do I need to have the [[ ]] around the condition? I'm getting a syntax error:

./Compare.sh: line 9: conditional binary operator expected
./Compare.sh: line 9: syntax error near `-q'
./Compare.sh: line 9: ` if [[ grep -q -w var file ]]'
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

New Variable with Existing variable( Urgent)

hi all, i want use the variable value as a new variable name. print output of new variable. for i in COMPUTER1 COMPUTER2 do flag_name=${i}_FLAG eval ${flag_name}=123 echo $i'_FLAG' done output is COMPUTER1_FLAG COMPUTER2_FLAG i need output as 123 123 (2 Replies)
Discussion started by: arvindng
2 Replies

2. Shell Programming and Scripting

folder existing and file existing

I want to look into a folder to see if there are any folders within it. If there are, I need to check inside each folder to see if it contains a .pdf file So If /myserver/myfolder/ contains a folder AND that folder conatins a .pdf file do X Else do Z I may have multiple folders and... (4 Replies)
Discussion started by: crowman
4 Replies

3. Shell Programming and Scripting

Bash: if condition as variable

How can I use a variable that has the conditions for the if statement stored in it? my test script condition=" || || " if "$condition" then echo "true" else echo "false" fi output $ ./test2.sh ./test2.sh: line 3: || || : command not found false (2 Replies)
Discussion started by: curlee2002
2 Replies

4. Shell Programming and Scripting

Change existing variable value only user enters non-empty string.

I haven't checked any installation script to see how this is done.. But I could not even do following simple task. How do I Change existing variable value only when user enteres non-empty string. ? #!/usr/bin/ksh uid="scott" # Assign new value user enters to uid, else leave it... (7 Replies)
Discussion started by: kchinnam
7 Replies

5. UNIX for Dummies Questions & Answers

creating a new variable from existing data

Hello, I have the following data set: TRAIT DOSE 40 0.4 30 0.3 95 1.2 120 1.7 85 1.4 136 1.8 134 1.8 40 0.4 30 0.3 95 1.2 120 1.7 85 1.4 136 1.8 134 1.8 40 0.4 30 0.3 95 1.2 (2 Replies)
Discussion started by: wolf_blue
2 Replies

6. Shell Programming and Scripting

Compare the two variable with if condition

Please help me with this: I need to compare two values in if condition in shell script but its goes always to else condition: TIME_CHECK=PM TIME-CLOCK=PM if ; then echo "You have access!" else echo "ACCESS DENIED!" fi (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

7. Shell Programming and Scripting

Script with variable and condition

Hello newbies question... I just need a script able to launch a command when a condition is matched : #!/bin/ksh SIZ = 'cat /nurp/control.lst|wc -l' if test "$SIZ" -gt 0 then echo 1 else echo 2 fi but I receive errors messages ./t2: SIZ: not found 2 whats wrong ? (5 Replies)
Discussion started by: vdurieu
5 Replies

8. UNIX for Dummies Questions & Answers

Variable in IF condition

In AIX, why is it variable VAR becomes true in the condition despite VAR was unassigned and not equal to 1? In Linux, it was traced as an error as VAR is not declared as variable and expecting an integer as argument. one.sh VAR=1 if ; then echo "One" fi if ; then echo "Two"... (5 Replies)
Discussion started by: budz26
5 Replies

9. Shell Programming and Scripting

Not able to assign 0 (zero) to the existing variable

Hi, I have a variable which read the value from the lines, and if it is empty string (5 bytes), then I have to assign this variable to zero "0", it able to detect the data is empty by showing me the message "empty", but not able to assign it as zero. WTHP=`echo "$file" | cut -c158-162` if ]... (5 Replies)
Discussion started by: newbie2011
5 Replies

10. Shell Programming and Scripting

Shell variable as awk condition

Hi, I'm trying to automate part of a script which uses awk to grab out some lines of a log file based on certain fields matching. For example, my log file looks something like the following (but 1000s of lines): 1 Tom 123 abc 345 2 Dick 345 abc 678 3 Harry 567 abc 345 4 Tom 345 cde 345... (3 Replies)
Discussion started by: chrissycc
3 Replies
__gnu_parallel::_GuardedIterator< _RAIter, _Compare >(3cxx)			       __gnu_parallel::_GuardedIterator< _RAIter, _Compare >(3cxx)

NAME
__gnu_parallel::_GuardedIterator< _RAIter, _Compare > - SYNOPSIS
Public Member Functions _GuardedIterator (_RAIter __begin, _RAIter __end, _Compare &__comp) operator _RAIter () std::iterator_traits< _RAIter > ::value_type & operator* ()" _GuardedIterator< _RAIter, _Compare > & operator++ ()" Friends bool operator< (_GuardedIterator< _RAIter, _Compare > &__bi1, _GuardedIterator< _RAIter, _Compare > &__bi2) bool operator<= (_GuardedIterator< _RAIter, _Compare > &__bi1, _GuardedIterator< _RAIter, _Compare > &__bi2) Detailed Description template<typename _RAIter, typename _Compare>class __gnu_parallel::_GuardedIterator< _RAIter, _Compare > _Iterator wrapper supporting an implicit supremum at the end of the sequence, dominating all comparisons. The implicit supremum comes with a performance cost. Deriving from _RAIter is not possible since _RAIter need not be a class. Definition at line 66 of file multiway_merge.h. Constructor &; Destructor Documentation template<typename _RAIter , typename _Compare > __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::_GuardedIterator (_RAIter__begin, _RAIter__end, _Compare &__comp) [inline] Constructor. Sets iterator to beginning of sequence. Parameters: __begin Begin iterator of sequence. __end End iterator of sequence. __comp Comparator provided for associated overloaded compare operators. Definition at line 84 of file multiway_merge.h. Member Function Documentation template<typename _RAIter , typename _Compare > __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::operator _RAIter () [inline] Convert to wrapped iterator. Returns: Wrapped iterator. Definition at line 105 of file multiway_merge.h. template<typename _RAIter , typename _Compare > std::iterator_traits<_RAIter>::value_type& __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::operator* () [inline] Dereference operator. Returns: Referenced element. Definition at line 100 of file multiway_merge.h. template<typename _RAIter , typename _Compare > _GuardedIterator<_RAIter, _Compare>& __gnu_parallel::_GuardedIterator< _RAIter, _Compare >::operator++ () [inline] Pre-increment operator. Returns: This. Definition at line 91 of file multiway_merge.h. Friends And Related Function Documentation template<typename _RAIter , typename _Compare > bool operator< (_GuardedIterator< _RAIter, _Compare > &__bi1, _GuardedIterator< _RAIter, _Compare > &__bi2) [friend] Compare two elements referenced by guarded iterators. Parameters: __bi1 First iterator. __bi2 Second iterator. Returns: true if less. Definition at line 113 of file multiway_merge.h. template<typename _RAIter , typename _Compare > bool operator<= (_GuardedIterator< _RAIter, _Compare > &__bi1, _GuardedIterator< _RAIter, _Compare > &__bi2) [friend] Compare two elements referenced by guarded iterators. Parameters: __bi1 First iterator. __bi2 Second iterator. Returns: True if less equal. Definition at line 128 of file multiway_merge.h. Author Generated automatically by Doxygen for libstdc++ from the source code. libstdc++ Tue Nov 27 2012 __gnu_parallel::_GuardedIterator< _RAIter, _Compare >(3cxx)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy