LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-20-2010, 06:13 PM   #16
rastin_nz
LQ Newbie
 
Registered: Oct 2010
Posts: 17

Original Poster
Rep: Reputation: 0

thanks so much!! that was it
 
Old 10-20-2010, 07:07 PM   #17
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Also, I assume you want the counter (i) to be 1 the first time it is used?
If so you can do the following:
Code:
#Set initial value to 1
i=1

while read -r  myxcoord myycoord
do
    <do some stuff>
    ./dc_2002 && ./st_vac
    cp motion.out "$i$stn$mt"
    cp time.out "$((i++))$stn$vel"
    <do more stuff>
done
Notice only the second copy needs to increment the counter.

And crts is correct that there should be no spaces in seds
 
1 members found this post helpful.
Old 10-20-2010, 07:10 PM   #18
rastin_nz
LQ Newbie
 
Registered: Oct 2010
Posts: 17

Original Poster
Rep: Reputation: 0
Hi Grail
I actually use a very similar one)
Code:
#!/bin/bash
stn="edrz"
mt="mt"
vel="vel"
i=0
d=5
rr=30
while read -r  myxcoord myycoord
do
echo $myxcoord 
echo $myycoord
echo $i
sed  -i.bak  "s/Xs=[^,]*/Xs=${myxcoord}/" dc.in
sed  -i.bak  "s/Ys=[^,]*/Ys=${myycoord}/" dc.in

./dc_2002 && ./st_vac
echo $((i++))
cp motion.out "$i$stn$d$mt$rr"
cp time.out "$i$stn$d$vel$rr"
rm motion.out
rm time.out
done  < <( paste  coordinatex.txt coordinatey.txt)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH: read every line in the files and use the line as parameters as another program tam3c36 Programming 10 12-07-2010 01:42 PM
open text file and read line by line amani_87 Linux - Software 20 01-28-2010 10:25 PM
bash : read every line from text file starting at given line number quadmore Programming 4 02-20-2009 12:29 PM
help with c program to read each line from text file, split line , process and output gkoumantaris Programming 12 07-01-2008 12:38 PM
read line by line form text file in java. spank Programming 1 10-18-2006 02:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration