03-26-2008
Help needed in converting number to bit
Hi,
I have the following file input:-
542 4795 61
543 4795 61
544 0 0
545 292 2
546 292 2
547 0 0
548 0 0
549 0 0
550 111 4
551 0 0
552 0 0
553 4614 63
554 4614 63
555 0 0
etc...
The first column basically is an known index. I would like to parse the second and third column to be bits.
In other words,
if I have
Index
1 2 2
2 4 5
I wanted to change to bit wise to:-
1 1
1 1
1 1
1 1
1 1
1 1
1 1
0 1
etc..
Can anyone help me on this. I tried using C and it works but I need to assign "while loop" for each index for the tokenization.IF that is the case, if I have thousands of indexes, i would have to have thousands of while.
Please advise. Thanks alot.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I've searched the forum and google, but can't see an answer to this simple problem. Here's my small test script:
#!/bin/csh
echo "enter a number:"
read num
echo "you entered $num"
set num = `expr $num + 1`
echo new value is $num
can someone show me how to do this calculation? note that... (4 Replies)
Discussion started by: tpatput
4 Replies
2. Shell Programming and Scripting
I have written a script to compare the values of string (which actually are numbers) but it is not giving the expected output. Please suggest for the script.
#!/usr/bin/ksh
sysdate=20071009
echo $sysdate
currfile=20071008
echo $currfile
if ; then
echo "Equal"
else
echo "Not... (2 Replies)
Discussion started by: raman1605
2 Replies
3. Shell Programming and Scripting
Hi All,
I am writing a shell script in which I want to convert a number like :
Suppose the number is "98487657" and we have to convert it to "98000000", what I want to do is to retain first 2 digits and convert all remaining digits to "0".
Number could be of any length (length... (4 Replies)
Discussion started by: amitanshu.verma
4 Replies
4. HP-UX
Dear All,
I am new on Tru 64 bit Unix platform. I have a database server "HP AlphaServer ES45" version p5.1 of Tru Ux 64 bit installed. I have 4 hard drives in this system (1,2,3,4). My 4th hard drive is damaged which contain Oracle database files including partitions on 4th drives... (2 Replies)
Discussion started by: hellozishan
2 Replies
5. UNIX for Dummies Questions & Answers
Hi ,
I have to install Oracle Enterprise linux 64bit version on my machine.
How would i determine whether my system is compatible for 64 bit version.
What is difference between 64 bit version and 32 bit version?
I heard that 64 bit version are suitable for machine with ram more than 4 gb... (5 Replies)
Discussion started by: pinga123
5 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I am having a problem in converting a string to number so I can preform arithmetic operations.
timeTot=0
timeTmp=$(cat idsOutput | grep 'Run time' | cut -c 36-39)
timeTot=$ #This is line 28
echo "total RunTime=" $timeTot
this is the error msg:
./ids2.sh: line 28: 0+1.35: syntax... (8 Replies)
Discussion started by: turki_00
8 Replies
7. Programming
I have an assignment in which a character is the input of which some bits(from a position to certain position) are to be inverted (1's complement) and then the resultant character is to be returned....for example
unsigned char x = J from p = 3 to offset n = 5
01001010 inverted to... (1 Reply)
Discussion started by: ezee
1 Replies
8. Programming
Is there a function to convert number (unsigned int for this example) to binary? I could not find a simple one thru google.
While I was learning bloom filter with the example, I was wondering if anybody can help me to
1) display the real bits vector for the bloomfilter;
2) if dataset is very... (11 Replies)
Discussion started by: yifangt
11 Replies
9. UNIX for Beginners Questions & Answers
Hi ALL,
I am having semi column separated file as below. I am having negative values for the records starting with 11095. How can I convert that positive number
I tried this below seems not working
sed 's/ \(*\)$/ -\1/;t;s/\(.*\)-/\1/ myfile
myfile... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies
shift(1) User Commands shift(1)
NAME
shift - shell built-in function to traverse either a shell's argument list or a list of field-separated words
SYNOPSIS
sh
shift [n]
csh
shift [variable]
ksh
* shift [n]
DESCRIPTION
sh
The positional parameters from $n+1 ... are renamed $1 ... . If n is not given, it is assumed to be 1.
csh
The components of argv, or variable, if supplied, are shifted to the left, discarding the first component. It is an error for the variable
not to be set or to have a null value.
ksh
The positional parameters from $n+1 $n+1 ... are renamed $1 ..., default n is 1. The parameter n can be any arithmetic expression that
evaluates to a non-negative number less than or equal to $#.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari-
able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not
performed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), ksh(1), sh(1), attributes(5)
SunOS 5.10 15 Apr 1994 shift(1)