Programming :: Variable Not Incrementing In C

Sep 10, 2010

It compiles fine, but gets stuck in the loop. z never increments. I was using a for loop originally but had the same problem so I decided to try a while loop.

[code]....

View 3 Replies


ADVERTISEMENT

Programming :: Replace String By Incrementing Number

May 30, 2011

Say I have a file as

[code]....

It would be great, if i could issue a command (Vi/Bash/awk, ...) in order to obtain

[Code]...

So, the "replace string" should be replaced by another string containing the counter of replacement.

View 7 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Programming :: Make A New Variable With The String From The Old Variable Btut Without Any Plus Sign?

Apr 7, 2010

my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.

i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't

foo=+12.40
bar=${foo#+}

View 4 Replies View Related

Programming :: Search Within A Variable And Assign The Results To A New Variable?

Apr 25, 2011

how I can search within a variable and assign the results to a new variable. I'll use the following as an example -

cars="Audi BMW Cadillac Chevy Dodge Ferrari Ford Mercedes"
list=`echo ${cars} | egrep -o '<A?+|<C+'`

with the echo command I get the following output assigned to list -

A
C
C

What I'd like to get for output is -

Audi
Cadillac
Chevy

how I could do this regardless of upper/lower case letters?

View 5 Replies View Related

Programming :: Assign Value Of C Variable To Shell Variable?

Apr 28, 2010

included shell script inside c program, and i wanted to assign the value of c variable to shell variable..Can any one please suggest me how to do it?

View 8 Replies View Related

Programming :: Assignment To A Variable Variable?

Mar 17, 2011

This loop is part of a bash script which takes multiple arguments.

Code:
for ((i=1;i<=$number;++i)) ; do
offset=$(($i+5))

[code]...

View 3 Replies View Related

General :: Incrementing Array Element In Shell Scripting

Jun 23, 2010

ch[1]=0; ch[2]=0; ch[3]=0; ch[4]=0; ch[5]=0; ch[6]=0; ch[7]=0; ch[8]=0; ch[9]=0; ch[10]=0;ch[11]=0; ch[12]=0; ch[13]=0; ch[14]=0; ch[15]=0 ch[16]=0; ch[17]=0; ch[18]=0; ch[19]=10; ch[20]=0;

I have an array ch and I want to increment each element in my array for the following if statement. I'm not sure I have the right array increment syntax but I have tried it in different ways ant it doesn't seem to work.

I tried ch[$1]++, ch[$1]+1, ch[$1++], ch[$1]+=1, ch[$1]=ch[$1]+1 none of these seem to work.
# while loop reading from read.txt for check list 1 - 15
for i in `seq 15`
do
a=`grep "${cl[$i]}" $file`
status=$?
if [[ $status = 0 ]];
then
echo -n -e "1 "
let ch[$i+1]
let k++
else
echo -n -e "0 "
fi
done
for l in `seq 20`
do
echo -n -e "${ch[$l]} "
done

View 2 Replies View Related

Software :: Cvs To Check In A Change Without Incrementing The Revision Number ?

Jul 23, 2010

Is there any way in cvs to check in a change without incrementing the revision number?

I know you can specify the revision number, but I'm under the impression that if you specify a revision that exists, it increments .1 to the right.

So if current revision is 1.2 and i specify -r 1.2 it will make the revision 1.2.1

View 1 Replies View Related

Programming :: Pass Variable In Mysql Qyery In C Programming?

Dec 4, 2010

i want to pass variable in mysql qyery in c programming

View 1 Replies View Related

Programming :: Sed A Variable In Bash?

Mar 25, 2011

I have beat this enough and don't get what should have been a very simple thing to do. I build a variable;

Code:
CLIST=java,lua,python,php,perl,ruby,tcl
CLIST will be used by another bash script but I need to replace the commas with a space. I

[code]...

View 2 Replies View Related

Programming :: C++ Get Variable Name From Document Name?

Apr 9, 2010

How would I go about defining a variable from a document name. Example:document01.doc I want to take the 01 and set X to equal integer 1.

View 1 Replies View Related

Programming :: Defining Variable With Sed?

Jun 2, 2010

I need to replace JAVA_OPTS= with JAVA_OPTS=<some_value>.I need to give "" value at the end of the replacement. I have tried with the following but it is not working: sed -e "s|JAVA_OPTS= |JAVA_OPTS=<some_value>"

View 2 Replies View Related

Programming :: Can Awk Take A Shell Variable

Jul 23, 2010

I have been searching most of today and am stuck on getting a variable into an awk portion of my bash script. I have this working:

Code:

#!/bin/sh
SRC=/var/log/mail.log
DEST=/var/www/output/myFile.txt
VAR=userName@myDomain.tld

[code]....

Can awk take a shell variable? Or do I have to do something completely different?

View 11 Replies View Related

Programming :: C++ Variable Type Followed By *?

Jul 1, 2010

In C++ what does the suffix, "*" mean appended to a variable type, e.g., "char* variable1;"?

View 3 Replies View Related

Programming :: Initializing A Variable In C?

Nov 5, 2010

Following is the way I saw a variable initialized in C

Code:

static const unsigned int rtl8139_rx_config =
RxCfgRcv64K |
(RX_FIFO_THRESH << RxCfgFIFOShift) |
(RX_DMA_BURST << RxCfgDMAShift);

on following link

[URL]

I have initialized variables in past but above initialization I could not understand what is it?

View 4 Replies View Related

Programming :: Print Variable Value In Awk?

May 16, 2011

problem statement:

pattern_search="Exam Name"
sed -n "/$pattern_search/,/hello/"p tmp5 | awk '{if ( $4 != 0 && $4 ~ /[0-9]+.*[0-9]*/ ) print "$pattern_search" " " $0 }'

"tmp5" is a file. this is printing output as

$pattern_search value1

i.e value of $pattern_search is not getting substituted. i am expecting output as

Exam Name value1

View 3 Replies View Related

Programming :: Retrieving Value From Variable

Feb 5, 2010

how shall I print each variable separately using a generalized form. I tried writing the following within a for loop...Code:echo $(echo a$(echo $i)$(echo $j))which did yield no result. So what shall I write??

View 3 Replies View Related

Programming :: Release Value Of Variable In Awk?

Mar 8, 2011

I have the following input:

Code:

Event 1............................................................
full_name: JENNY_JENNINGS genre: f
age: 32

[code]....

But as you can see in the input, in the 2nd "Event", the line containing "age" is not present, but in the output my code is printing the 1rst age value twice. The correct output should be blank in the age field for 2nd line in the output like this:

Code:

full_name|genre|age|code
JENNY_JENNINGS|f|32|15a
JOHN_JOHNSON|m||23c
MARY_JEAN|f|25|11d

What is wrong in my code? how can I fix it? * I�m using ubuntu 10.10

View 12 Replies View Related

Programming :: Set Environment Variable Is Tcl ?

Apr 22, 2011

How are environment variable set in tcl? I tried "set $env(MYVAR) xxxx" but it didn't work.

View 1 Replies View Related

Programming :: Using Variable In A Command?

Apr 14, 2011

i'm trying to execute a shell script, i'm trying to use the values in an array for use in a sed command:

sed -n '/Sales ID: ${array[$i]}/,/Totals:/p'

that command creates empty files. so my guess is that its not recognizing the array as an array but as text?
how would i be able to utilize the array in the command? i got it, didnt think that if i doubled up the single quotes that it would work, but this worked:

sed -n '/Sales ID: '${array[$i]'}/,/Totals:/p'

View 4 Replies View Related

Programming :: Variable Is Gone At The End Of While Loop?

Mar 25, 2011

I have a directory file capturing script, the variable is fine with in the loop but gone after the loop is done:

Code:
DIR="/usb/sdb1/media/music/"
i=1

[code]...

View 9 Replies View Related

Programming :: Variable Name Change In A Loop?

Apr 24, 2010

I am about to move my scripts to the next generation level, so I need some help I am stuck in varying my variable names in a loop. For example:

for user in ben dorothy mike pat
do
[ -r /home/$user ] && let "$user"check=1 || let "$user"check=0

[code]...

View 1 Replies View Related

Programming :: Variable Substitution In BASH?

Feb 17, 2011

Just a simple BASH for loop to read the file path from a text file (clean.txt) echo the variable for debug purposes, and scp it to a server I have using port 50 for SSH.

I've already formatted the entries in clean.txt to handle spaces correctly, using sed replacement.

Example from the clean.txt file:

Code:
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/20 Auld Lang Syne.mp3
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/14 Deck the Stills.mp3

[Code]....

View 5 Replies View Related

Programming :: Dereferencing Exported Variable?

Jul 6, 2010

This is probably a very easy thing to do, but I don't know how: I'd like to export an env't variable, and then use its reference in a Bash script

Code:

View 5 Replies View Related

Programming :: Script With Variable In If Statement?

Jul 9, 2010

I am trying to create a script to be used on RHEL server. If I replace the $t with a number, the script works. If I try add a variable or the $1, the script doesn?t work (returns all processes even if less than the $t value). I thought that it may be treating it as a literal, but I wasn?t sure of the conversion.

t=$1
echo $t
lcnt=`ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww --sort=pid | awk '{if ($6 > $t) print

[code]...

View 2 Replies View Related

Programming :: Read A Foldername Into A Variable?

Jul 14, 2010

I am trying to write a script which can read the names of all folders within a given folder into separate variables. In effect, if a folder contains a folder "Folder1", "Folder2", "Folder3", the script would read those names into variables such as:

Variable1 = "Folder1"
Variable2 = "Folder2"
Variable3 = "Folder3"

I have tried fiddling with the find . command, but without any success.

View 3 Replies View Related

Programming :: UUID Save As A Variable?

Jul 22, 2010

I am new to linux scripting, but I have programming experience. I need to save the UUID for /dev/sda1 as a variable, lets call it id. I am sure there is a way to do this with the awk and blkid commands, but I do not know any of this well enough yet to figure it out and after a couple of hours of reading I am still lost as to exactly how I would put this together. I need to save the uuid as a variable so that I can run an if statement with it

if [ -f /media/$id/file ]
then
echo "copy successful"
else
echo "oh crap!"

honestly all I need the uuid for but I cant check this by doing the same if with /dev/sda1/file so I need to be able to save the uuid into a variable

View 7 Replies View Related

Programming :: How To Use Bash Variable In C Code?

Feb 16, 2011

I want to write a c program with some shell scripts.Now For a simple C program. I am Setting a variable called val2 in bash, now I want to use bash variable val2 in C code. How do I do that?The above doesn't work (coz its spawning a different memory space and when shell script ends the variable dies with it as per my research but how do I keep them in same memory space)Also Is there any Good reference where they teach how to integrate C and Bash Together?

View 5 Replies View Related

Programming :: Pass Variable Between Scripts?

Mar 9, 2011

I need to pass variable from sc1.sh to sc2.sh and update the value of the passed variable in sc2.sh and then return the updated value of the variable from sc2.sh to sc1.sh.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved