General :: Written A Script In Which, Changes A Variable Using A "while" Loop?

Feb 8, 2010

i have written a script in which, i changes a variable using a "while" loop. then i feed that variable to an input file. After that i run that file in parallal using mpi library.Script is as:>>>>

#!/bin/bash
STA=/home/sk/Desktop/exefile
sta=mpirun -np 6 $STA

[code]....

View 14 Replies


ADVERTISEMENT

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

General :: Recalculate Variable For Each Pass Of An Until Loop?

Feb 11, 2010

I am trying to write a script that will find any user on the server running more than one instance of the epiphany web browser process, then kill all their epiphany pids. (This is necessary sometimes to cure lockups, and repeat processes are the telltale sign in this case). I have tried implementing the until loop:

Code:
USER=`ps aux | grep epiphany | grep -v grep | sort | uniq -d -w 5 | awk '{print $1}'`
until [[ "$USER" == "" ]]
do
ps aux | grep epiphany | grep -v grep | grep $USER | awk '{print $2}' | sudo xargs kill
done

Unfortunately, the script only calculates the USER variable once at the beginning of the script. Fair enough, that's how it's written. My question is, how would I get the USER variable to update for each pass of the until loop so that it could cure multiple users of this ailment if necessary? That is, calculate $USER, kill their epiphany pids, repeat those two steps until the $USER variable comes up blank, then exit.

View 5 Replies View Related

General :: Shell Script - Use Variable In A For Loop With Directory Path?

Jan 19, 2011

I modified files in several directories, and need to run a diff on the backup I created before modifying the file.

I'm trying to compose a simple shell script to speed up the task, but getting a syntax error.

Here is what I have:

for i in DIR1 DIR2 DIR3 DIR4 DIR5 do;
diff /maindir/subdir/subdir/$i/filename.txt.old /maindir/subdir/subdir/$i/filename.txt;
done

I know the paths are valid, and if I run just the diff command with the actual DIR1 instead of $i it works.

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

Ubuntu :: Lost Variable Value Out Of Loop?

Jan 27, 2011

I really don't get this!! I must be doing something really foolish but i can't figure out what it is.

Code:
#!/bin/bash
pro_num=0

[code]...

View 4 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 :: Using A Variable To Control A BASH For Loop

Jul 3, 2009

I know of 4 different ways to use a for loop:

1. for I in {1..10}; do echo $I; done|

2. for I in 1 2 3 4 5 6 7 8 9 10; do echo $I; done|

3. for I in $(seq 1 10); do echo $I; done|

4. for ((I=1; I <= 10 ; I++)); do echo $I; done

I have a script which uses the 1st form of for loop. I'm trying to modify it to use a variable instead of a static hard-coded value in the section that controls the looping.of the for loop.

I've tried all different ways of quoting and escaping the variable, and the problem is that the quoting chars and escape char are being translated and passed into the loop along with the value stored in the variable.

For example, to change the start value of 1 to whatever value I want passed in through a variable:

Change:

I have tried: {{$a}..10} and {`$a`..10}, to have the variable evaluated first.

I have tried using the eval() function.

I have tried single and double quotes and the backslash escape character.

Nothing I've tried works. It's probably a syntax error.

View 14 Replies View Related

Server :: Bash Mayhem With For Loop And Variable Range

Mar 1, 2011

As you can see on the output of the script, the two 'testing echoes' I do at the end don't print anything.That's the point, I do NEED this array further in my script.I'd understand my "param" var is local to the for, but is the other one too ? I tried to use "declare -a file" before the for, but i get same exact result !

View 2 Replies View Related

Programming :: Bash Variable Parsing / Extract And Put Into Variables Each Combination Of F1 And F2 In A Loop?

Oct 14, 2010

I have a bash variable where the content looks like this where ;f1; and ;f2; are delimiters:
;f1;field1value1;f2;field2 value1 ;f1;field1value2;f2;field2 value2 ;f1;field1value3;f2;field2 value3

So what I need is to extract and put into variables each combination of f1 and f2 in a loop to something like that:

#first pass of the loop I need:
f1=field1value1
f2=field2 value1

#second pass of the loop I need:
f1=field1value2
f2=field2 value2

# third pass of the loop I need:
f1=field1value3
f2=field2 value3

View 15 Replies View Related

Programming :: Perl's Foreach Loop Can't Use An Array Element As The Control Variable?

Jul 22, 2011

I'm reading "OReilly Learning Perl 5th Edition", and there are such words:Code:You can use an array element like $fred[2] in every place? where you could use any other scalavariable like $fred.At the bottom of the page, it explains the ? like this:Code:The most notable exception is that the control variable of a foreach loop, which you?ll see later in this chapter, must be a simple scalar.Since Perl has the save-and-restore mechanism for the control variable, why an array element can't be used as the control variable

View 1 Replies View Related

General :: For Loop Or While Loop To Read The Fields Of A File?

Sep 1, 2010

I have a mytext file with month and year as two separate fields. likemytext fil

08 2010
09 2010
10 2010
........
........
........

I want to read the values of each field i.e., month and year into an awk script.

View 10 Replies View Related

Programming :: SH: Passing A Variable Out Of A "while - Do - Done" Loop

Jul 3, 2011

"While ; do ; done" is very convenient for SH coding. However sometimes you may be annoyed by your computed variable within the "while do done" type loop. What to do how to pass it out of the loop to the outside of the bash code? A solution is to write it into the /tmp or on the disk... and to call it back after. - not elegant... really not... Anyone would know a trick another alternative that would look nicer?

Code:
# Count file total size
TOTAL_SIZE=0
LISTOFFILES=`cat "$HOME/.fvwmoscfg/fvwmburnerlist.lst"`
echo "$LISTOFFILES" | while read i ; do
SIZE=`du -bs $i | cut -f 1`
TOTAL_SIZE=`expr $SIZE + $TOTAL_SIZE`
echo "$TOTAL_SIZE" > "$HOME/.fvwmoscfg/fvwmburnerlisttotalsize.lst"
done
TOTAL_SIZE=`cat $HOME/.fvwmoscfg/fvwmburnerlisttotalsize.lst`

echo "The total size of all files and folders is : $TOTAL_SIZE"

View 8 Replies View Related

General :: Assign Local Variable Values To Global Variable?

Feb 17, 2011

how to assign a local variable value to a global variable....

View 2 Replies View Related

General :: Create An Environment Variable With The PRINTER Variable?

Apr 16, 2011

I am supposed to create an environment variable with the PRINTER variable, which should resolve to the word sales. Would the command be like this?: env PRINTER - NAME=SALES (is this the command to create that variable with resolving the word sales to it?)

View 3 Replies View Related

General :: /var/log/messages Is Not Being Written To?

Nov 1, 2010

I was attempting to get crontab to kick off a daily job, but the job wont start. I opened /var/log/messages and noticed all the logs were from 6 months ago. I cleared the log and then did a tail -f so I could watch it for activity. I then hit my box with anunsuccessful log in attempt. Nothing happened to the log. The uptime of my box is 22 days and the logs that were in it before I cleared it were from months ago.Is there a daemon I can check or another file I can mod to get logs writing again?

View 3 Replies View Related

General :: Monitor Written Data From Dd?

Aug 22, 2010

I have a huge disk image backed up using dd.
I need to restore the disk image but dd is very silent.

How can I monitor its progress?

View 3 Replies View Related

General :: How To Remove Over Written Lines

Apr 19, 2010

I need to filter the log from a massive wget. I want to remove the progress lines and only leave the last one. Now each progress line starts with a newline '

View 2 Replies View Related

General :: New OS Only Recognizes Blank Dvd Not Written Ones?

Apr 4, 2011

I don know how this happened, but my system only recognizes an disk when the disk is blank. If thereÅ› anything on it it won mount it. Why is this happening?

View 6 Replies View Related

General :: Use The Value Of One Variable To Generate A Name For Another Variable?

Jul 25, 2010

can i use the value of one variable to generate a name for another variable? for example i want to use the counter from a "do while" loop to name and define a variable each time the loop executes. for example

objectnames1=`ls -a`
objectnames2=`ls -a`
etc.

i don't have a script yet but each time through the loop i intend to cd to a particular directory and then define a variable containing a list of each object in that directory as values. for the rest of the script to work, each variable generated has to be unique, and i can't think of a good way to accomplish this.

if using a value from one variable to name another isn't possible, can anyone think of a more elegant solution? i know limited syntax but i'm willing to read up...

View 6 Replies View Related

General :: Sed Substitution Of Variable With A Variable?

Dec 27, 2010

I am trying to alter the character position of residue numbers above 999 in a pdb file.The following script is an attempt to:1) Get all unique pdb residue numbers (in column 5) using awk and assign it to a variable i.2) Loop through all the values in $i and if it is greater than 999, shift that number one character to the right using sed.However, the script only manages to alter the final residue numberCould anyone please advise how I can loop through all values in $i and shift it one character to the right?

#!/bin/bash
# Script to alter position of residue number in pdb file for resid above 999
i=$(awk '{print $5}' wt-test.pdb | uniq)

[code]...

View 6 Replies View Related

General :: Terminal Emulators Written In Java?

Nov 21, 2010

I'm looking for a terminal emulator that does the same thing as gnome-terminal or konsole, except written in Java.

View 2 Replies View Related

General :: Data Written To Unformatted Disk

Jan 14, 2011

I went and fdisk'd a USB disk and put the Fat32 filesystem onto it. Then I thought I ran dosfsck over it which I thort formatted the disk - apparently not. Then I copied a bunch of files and directories to it. Now I am unable to recover the files and data. In the rare instances when I perform a sloppy mount I see directories named 001, 002, 003 and 004. These directories variously contain files named 001, 002, 004 (no 003) etc.

Fdisk gives me:

I don't know enough to use dd, kpartx, parted, partmon, partprobe, partx et al

View 1 Replies View Related

General :: GRUB Got Re-written By The Windows Bootloader?

Feb 14, 2011

with reference to my this thread: [URL]

After installing Windows 7, the GRUB got re-written by the windows bootloader. Now after booting into the live cd and mounting /boot partition (sda2), I tried to reinstall the GRUB with this command grub-install --root-directory=/mnt /dev/sda as told by this [URL]

But I got the an error which says, Are you sure /dev is mounted? then i tried the same command on the / partition (sda5) which said, cannot find boot directory, Are you sure /dev is mounted?

And installation failed, now after restarting its just a black screen with grub> prompt.

View 13 Replies View Related

General :: Debug A Newly Written System Cal?

Dec 17, 2010

i added a new system call..helloworld...

i rebuild the kernel and when i try to use it, it is returning -1.

can any one tell me how to debug and know where things went wrong..

how to see the kernel log when this syscall is called...i wrote a println in my syscall..but couldnt find that in /var/log/dmesg...

View 3 Replies View Related

General :: Catch All Data Being Written To Hard Drives?

Jul 18, 2010

I have a Linux CentOS server.Is there a way to store all changes made to the hard drive by all software on the server ?

View 14 Replies View Related

General :: Finding A File Which Is Being Written Recently In Directory Of 1000 Files?

Apr 13, 2011

How to find a file which is being written recently in directory of 1000 files?

View 8 Replies View Related

General :: Download Linux Network Administrator Guide Written By Kirch?

May 3, 2011

HOW can i download Linux Network Administrator guide written by Kirch?

View 9 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

Software :: Get Variable From Text File Into Bash Variable?

Jun 10, 2009

I have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?

View 2 Replies View Related







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