06-08-2009
if both variables contain string without space
if [ $var1 = $var2 ] ; then
will work
if they have space put variables in double qoutes
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need some help which would probably be for most of you a simple script.
I need to read in the data from a .dat file and then compare avg to see who is the highest avg. Here is my script so far.
#!/bin/ksh
#reading in the data from lab3.dat
filename=$1
while read name o1 o2 o3 o4 o5 o6... (0 Replies)
Discussion started by: bluesilo
0 Replies
2. Shell Programming and Scripting
hi,
I want to compare i variable in the awk statement but its not working out. Pl help me out
If we do the comparison like this its OK,
cat sample | awk -F" ", '{if ($1=="1-Sep-2009") print $1,$2,$3,$4,$5}'
But if u use a variable instead of "1-Sept-2009", it does not return anything,... (2 Replies)
Discussion started by: asadlone
2 Replies
3. Shell Programming and Scripting
Hi all,
I have a variable say var1 (output from somewhere, which I can't change)which store something like this:
echo $var1
name=fred
age=25
address="123 abc"
password=pass1234
how can I make the variable $name, $age, $address and $password contain the info?
I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies
4. Shell Programming and Scripting
Can anyone help me with this section of code?
The scenario is a value drops from A to B or A to C or B to C.
If it drops from A to B or B to C, we print "Drop one level"
If it drops from A to C, we print "Dropped two levels".
The problem is script is throwing error when comparing variable... (2 Replies)
Discussion started by: sundar63
2 Replies
5. Shell Programming and Scripting
Hi all,
How I could compare variable and regexp?
For example...
I am running the script ./aaa.sh -b *
* is variable $2 (second argument of script).
I would compare variables $a (generated from my cycle) and $2 as regexp.
I need from regular expression find file that satisfies this regexp.... (1 Reply)
Discussion started by: Koblenc
1 Replies
6. Shell Programming and Scripting
Foo.txt
20 40 57 50 22
51 66 26 17 15
63 18 80 46 78
99 87 2 14 14
51 47 49 100 58
Bar.txt
20 22
51 15
63 78
99 55
51 58
How to get output using awk
20 22 57 50
51 15 26 17
63 78 80 46
99 55 - -
51 58 49 100 (5 Replies)
Discussion started by: genehunter
5 Replies
7. Shell Programming and Scripting
So, I'm making a little awk script that generates a range-based histogram of a set of numbers. I've stumbled onto a strange thing. Toward the end of the process, I have this test:
if ( bindex < s )
"bindex" is the "index" of my "bin" (the array element that gets incremented whenever a... (2 Replies)
Discussion started by: treesloth
2 Replies
8. Shell Programming and Scripting
Hi All,
I want to compare the variable value with string in a shell script.
my code is:
for var in $packsName
do
if
then
echo $var
fi
done
But I am getting error as:
ABC : not found.
Am I going wrong somwhere?
please guide.
Thanks. (5 Replies)
Discussion started by: AB10
5 Replies
9. Shell Programming and Scripting
Hello folks,
I have two files, which have usernames, I want to see the contents of file1.txt which is missing in file2.txt and another comparison file2.txt contents which is missing in file1.txt. please suggest.
file1.txt
user
u2
u8
a9
p9
p3
u4
z8
aaa
ahe
oktlo (7 Replies)
Discussion started by: learnbash
7 Replies
10. Shell Programming and Scripting
Hi , Need help, p
for value in `awk -F, '{print $1 }' ad | uniq`
do
x=$(echo $value)
echo $x
echo `awk -F, '{if( $1 == $x) sum = sum + $8 } END{print sum}' ad` --- not working
echo `awk -F, '{if($1 == “MT”) sum = sum + $8 } END{print sum}' ad` -- Working but hard coded
done;
ad... (4 Replies)
Discussion started by: nadeemrafikhan
4 Replies
LEARN ABOUT LINUX
atomic_ops
atomic_ops(3C) atomic_ops(3C)
NAME
atomic_ops - atomic operations
SYNOPSIS
#include <atomic.h>
This collection of functions provides atomic memory operations. There are 8 different classes of atomic operations:
atomic_add(3C) These functions provide an atomic addition of a signed value to a variable.
atomic_and(3C) These functions provide an atomic logical 'and' of a value to a variable.
atomic_bits(3C) These functions provide atomic bit setting and clearing within a variable.
atomic_cas(3C) These functions provide an atomic comparison of a value with a variable. If the comparison is equal, then swap in a new
value for the variable, returning the old value of the variable in either case.
atomic_dec(3C) These functions provide an atomic decrement on a variable.
atomic_inc(3C) These functions provide an atomic increment on a variable.
atomic_or(3C) These functions provide an atomic logical 'or' of a value to a variable.
atomic_swap(3C) These functions provide an atomic swap of a value with a variable, returning the old value of the variable.
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Stable |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
atomic_add(3C), atomic_and(3C), atomic_bits(3C), atomic_cas(3C), atomic_dec(3C), atomic_inc(3C), atomic_or(3C), atomic_swap(3C), mem-
bar_ops(3C), attributes(5)
Atomic instructions ensure global visibility of atomically-modified variables on completion. In a relaxed store order system, this does
not guarantee that the visibility of other variables will be synchronized with the completion of the atomic instruction. If such synchro-
nization is required, memory barrier instructions must be used. See membar_ops(3C).
Atomic instructions can be expensive. since they require synchronization to occur at a hardware level. This means they should be used with
care to ensure that forcing hardware level synchronization occurs a minimum number of times. For example, if you have several variables
that need to be incremented as a group, and each needs to be done atomically, then do so with a mutex lock protecting all of them being
incremented rather than using the atomic_inc(3C) operation on each of them.
12 Aug 2004 atomic_ops(3C)