LinuxQuestions.org
Visit Jeremy's Blog.
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 01-27-2010, 06:13 PM   #1
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Rep: Reputation: 21
Small Advanced Bash Script For Copy/Paste....


I'd sure appreciate a solution to my problem if anyone can help me?

I have a series of variables like so:
$BLACKPASS=7
$BLACKCUTDEPTH=567
$SURFACE=325
NUMBEROFPASSES=$((($BLACKCUTDEPTH-$SURFACE )/$BLACKPASS)) #is 34

Text To Edit:
IN;
PU;
SP6;
!PZ-300,200; snip here (inclusive)SP6 is a known/usable starting point
VS25;
PU9170,-10213;
PD9170,-10827;
PD7967,-10827;
PD7967,-10213;
PD9170,-10213;
PD9170,-10213;
PU9170,-10213; snip stops here inclusive BEFORE the next SPx line
SP7;
!PZ-300,200;
VS8;
PU8074,-9384;
PD8266,-8972;
PD8036,-8580;
PD8487,-8636;
PD8789,-8296;
PD8876,-8742;
PD9292,-8924;
PD8894,-9144;
PD8850,-9597;
PD8518,-9286;
PD8074,-9384;
PD8074,-9384;
PU8074,-9384;
PU;
PU30000,20000;IN;

What I need to do is take the snip and duplicate it and paste it at the end snip point over and over via a loop I already have based on $NUMBEROFPASSES. As each snip gets pasted in line the !PZ-xxx,200 needs to be changed in relation to the diff $BLACKCUTDEPTH-$SURFACE which is 242. I need the number 242 equally divided up over the number of snips and the increasing incremental diff. patched where the xxx is in !PZ-xxx,200.(the first !PZ-xxx,200 is left alone and all following strings have the patch applied increasing in numerical value. The 200 stays constant as do the SP6; and others SP#'s. The size of the snip will vary from a few lines to a thousand.
Can this be achieved via sed and awk? I sure hope so.

Thanks
Gary
 
Old 01-27-2010, 06:59 PM   #2
gary_in_springhill
Member
 
Registered: Mar 2008
Posts: 136

Original Poster
Rep: Reputation: 21
followup

For consistincy sake substitute !PZ325,200; instead of !PZ300,200; as the first value in the text where it gets sniped. The 325 will always equal $SURFACE
 
  


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
Script: SED for Copy/Paste Lines from Files unihiekka Programming 2 10-07-2008 06:12 AM
Very small bash script enemorales Programming 8 02-25-2005 02:47 AM
small bash script issue zoomzoom Linux - General 7 06-08-2004 06:33 PM
how to copy and paste between text editors sessions in bash pxes351 Linux - Newbie 2 05-06-2004 06:59 AM
sed in small BASH script OhLordy Linux - General 1 08-29-2003 11:32 AM

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

All times are GMT -5. The time now is 02:51 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