Plus edit and edit header


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Plus edit and edit header
# 8  
Old 11-14-2012
OK, try this (building on Rdrtx1's proposal):
Code:
awk -v cn="$CultureName" -v v1=$v1 -v v2=$v2 '
    BEGIN    {print "Cartograpic data in user defined format";
         print "....V....1....V....2....V....3....V....4....V....5....V....6....V....7";
        }
    NR==NL+1 {a=$0; print "p " cn;}
    {printf ("%12.2f%14.2f\n", $1+v1, $2+v2)}
    a==$0 && NR>NL+1 {print "999999"; NL=NR}
    ' file
Cartograpic data in user defined format
....V....1....V....2....V....3....V....4....V....5....V....6....V....7
p output_test_tri
   236604.80     572653.50
   236638.70     572696.00
. . . 
   236541.60     572489.50
   236604.80     572653.50
999999
p output_test_tri
   319290.10     532834.00
   319407.90     532870.00
. . .
   319568.20     531223.50
   319290.10     532834.00
99999


Last edited by RudiC; 11-14-2012 at 07:01 AM.. Reason: Had to modify code for > 1 packet changes
This User Gave Thanks to RudiC For This Post:
# 9  
Old 11-15-2012
Hi RudiC and Masters,

I have tried to mix your proposal and Rdrx1 proposal, here the script
Code:
#!/bin/bash

echo "Input_XY_File = "
read InputFile
echo "Culture Name = "
read CultureName
echo "Input Offset Variable 1 = "
read v1
echo "Input Offset Variable 2 = "
read v2
awk -v cn="$CultureName" -v v1=$v1 -v v2=$v2 '
BEGIN {
  print "Cartograpic data in user defined format";
  print "....V....1....V....2....V....3....V....4....V....5....V....6....V....7";
  print "p " cn;
}
NR==NL+1 {a=$0;print "p "cn;}
         {printf ("%12.2f%14.2f\n",$1+v1,$2+v2)}
a==$0 && NR>NL+1 {print "99999"; NL=NR}'
END {
  printf("%12.2f%14.2f\n",a,b);
  print 99999;
}
' $InputFile > $CultureName.dat

And after run script, I get this, there is no output created, see the resultt below. Sorry to bother you again, I don't know much about unix script.



Input_XY_File =
huhuhu1
Culture Name =
outpuc_cult_xxx
Input Offset Variable 1 =
651598.50
Input Offset Variable 2 =
5695659.50
Cartograpic data in user defined format
....V....1....V....2....V....3....V....4....V....5....V....6....V....7
p outpuc_cult_xxx

p outpuc_cult_xxx
651598.50 5695659.50

651598.50 5695659.50
99999

p outpuc_cult_xxx
651598.50 5695659.50

651598.50 5695659.50
99999

p outpuc_cult_xxx
651598.50 5695659.50

651598.50 5695659.50
# 10  
Old 11-15-2012
Tja, if you mix programs, you get mixed results.
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Edit Text

Hi everyone , i am new in shell scripting and i want to do a simple job. A have in a file a text that looks like : 4770 maniac 20 0 13680 312 240 S 0.0 0.0 0:00.00 pro 4770 maniac 20 0 23448 312 240 S 0.0 0.0 0:00.00 pro 4770 maniac 20 0 33216 312 240 S 0.0 0.0 0:00.00 pro and i want to... (2 Replies)
Discussion started by: pcmaniac
2 Replies

2. Shell Programming and Scripting

Best way to edit a file

looking for a script or command to push out from a centralized machine to multiple machines. I have the software in place that will do this already, but I need to tell it what command to run on each machine with this file. what I need is a script or command to edit a file in a specific manner.... (13 Replies)
Discussion started by: skunky
13 Replies

3. Shell Programming and Scripting

edit command

printf '3d\nw\nq\n' | ed -s file please explain the above command what the (ed -s file) will do by getting the first input. (1 Reply)
Discussion started by: thelakbe
1 Replies

4. Linux

Edit Grub? help!

Please help! I have installed 5 Linux OS in the following order: 1st : OpenSUSE 11.0 2nd : Ubuntu 8.4 3rd : Ubuntu 8.10 4th : OpenSUSE 11.1 5th : Fedora 10 Here is the scenario, at the 4th installation i can still choose which OS to boot as what OpenSUSE grub displays. Now, after... (3 Replies)
Discussion started by: etcpasswd
3 Replies

5. Solaris

how to edit /etc/vfstab

I created a file system earth in /earthpool (zpool). I mounted the file system on a directory /earth. But, when I reboot my machine it doesn't load the file systems and the zpool and zfs shows no pools available and no datasets respectively. I am using Solaris 10 running on X4500. Could you... (5 Replies)
Discussion started by: bharu_sri
5 Replies

6. Shell Programming and Scripting

Edit value in File

I have a file oratab with entry like this SCADAG:/esitst1/oracle/product/9.2.0.8:Y I am trying to discover a way to change the 9.2.0.8 part of this to something like 10.2.0.4 as part of an upgrade script. I have tried cat /etc/oratab >>/tmp/oratab... (1 Reply)
Discussion started by: sewood
1 Replies

7. Shell Programming and Scripting

HP-ux: Script edit

Hallo Friends, I have written a script which goes through different directories deleting files but I think there is a shorter way I can do this please help. #!/bin/ksh #set -x cd /minotaur/Data/CFD_Input/E_CIF cd 051 for files in 2008* do rm -rf $file done # cd ../052 for... (3 Replies)
Discussion started by: kekanap
3 Replies

8. UNIX for Dummies Questions & Answers

Edit the File

Hello Everyone I am new to this forum. I am having a requirement to edit the file(the file is having some sql code). And this file is in my colleagues login. This is readonly Now I would like to edit this file. In which way can I do this? (1 Reply)
Discussion started by: pradkumar
1 Replies

9. Shell Programming and Scripting

file edit help

Hi, Could anyone give me a idea how to strip the lines from a given file. example *********** 1st occurence 1st occurence 1st occurence 1st occurence *********** 2nd occurence 2nd occurence 2nd occurence 2nd occurence 2nd occurence 2nd occurence ************* 3rd occurence 3rd... (10 Replies)
Discussion started by: sentak
10 Replies

10. UNIX for Dummies Questions & Answers

VFSTAB edit

Hello all... I have a Ultra 60 that that is used for connecting a large Xerox printer to the network. This computer takes PDF's and converts them to tiffs and sends them back to a pc :p . In order to transfer data back and forth a mount is manually performed on the UNIX box. The mount of course is... (1 Reply)
Discussion started by: xeroxguy
1 Replies
Login or Register to Ask a Question