Sponsored Content
Full Discussion: Plus edit and edit header
Top Forums Shell Programming and Scripting Plus edit and edit header Post 302730655 by ipatah on Tuesday 13th of November 2012 11:18:05 AM
Old 11-13-2012
Plus edit and edit header

Dear Masters,

i have a problem with unix script, till now i just know about how to create header.

i want to change file below

Code:
     -63395.2      72653.5                                                                    
     -63361.3      72696.0                                                                    
     -63260.6      72743.0                                                                    
     -63138.8      72776.5                                                                    
     -63014.2      72804.5                                                                    
     -62944.7      72811.0                                                                    
     -62919.4      72805.5                                                                    
     -62845.8      72817.0                                                                    
     -62737.4      72828.0                                                                    
     -62342.5      72544.5                                                                    
     -62165.0      72414.5                                                                    
     -61982.8      72218.5                                                                    
     -61948.9      72141.5                                                                    
     -61891.4      72031.5                                                                    
     -61858.5      71868.0                                                                    
     -61869.4      71840.5                                                                    
     -61909.1      71755.0                                                                    
     -61930.1      71673.5                                                                    
     -61985.4      71618.5                                                                    
     -62064.8      71569.0                                                                    
     -62149.1      71555.5                                                                    
     -62288.1      71540.0                                                                    
     -62386.9      71549.0                                                                    
     -62456.0      71578.5                                                                    
     -62526.1      71640.5                                                                    
     -62563.0      71684.0                                                                    
     -62644.8      71777.0                                                                    
     -62697.4      71854.0                                                                    
     -62722.4      71890.0                                                                    
     -62776.6      71942.0                                                                    
     -62885.2      72015.0                                                                    
     -63018.1      72088.0                                                                    
     -63113.4      72158.5                                                                    
     -63197.4      72175.0                                                                    
     -63262.2      72237.0                                                                    
     -63299.2      72266.0                                                                    
     -63341.6      72299.5                                                                    
     -63419.7      72366.5                                                                    
     -63450.8      72459.0                                                                    
     -63458.4      72489.5                                                                    
     -63395.2      72653.5                                                                    
      19290.1      32834.0                                                                    
      19407.9      32870.0                                                                    
      19560.8      32861.5                                                                    
      19711.9      32841.5                                                                    
      19859.7      32788.0                                                                    
      19930.6      32681.0                                                                    
      19998.9      32579.5                                                                    
      20082.2      32434.0                                                                    
      20150.2      32321.0                                                                    
      20128.3      32105.0                                                                    
      20114.5      31894.5                                                                    
      20079.3      31679.0                                                                    
      19936.8      31543.0                                                                    
      19807.8      31418.0                                                                    
      19695.7      31276.0                                                                    
      19568.2      31223.5                                                                    
      19407.9      31249.0

here, my logic is

1. I have input as above
2. I have to know above file is devide into 2 group (begin and end character is same, ex 19407.9 31249.0)
3. I have another input, the value is 651598.50 and 5695659.50
4. I have to add 651598.50 to field 1 and 5695659.50 to field 2
5. I have to give a header (p output_test_tri) and end character (99999) every group.
5. I have to give a main header as below
Cartograpic data in user defined format
....V....1....V....2....V....3....V....4....V....5....V....6....V....7



and ouput should be as below




Cartograpic data in user defined format
....V....1....V....2....V....3....V....4....V....5....V....6....V....7
Code:
p output_test_tri 
   588203.30 5768313.00
   588237.20 5768355.50
   588337.90 5768402.50
   588459.70 5768436.00
   588584.30 5768464.00
   588653.80 5768470.50
   588679.10 5768465.00
   588752.70 5768476.50
   588861.10 5768487.50
   589256.00 5768204.00
   589433.50 5768074.00
   589615.70 5767878.00
   589649.60 5767801.00
   589707.10 5767691.00
   589740.00 5767527.50
   589729.10 5767500.00
   589689.40 5767414.50
   589668.40 5767333.00
   589613.10 5767278.00
   589533.70 5767228.50
   589449.40 5767215.00
   589310.40 5767199.50
   589211.60 5767208.50
   589142.50 5767238.00
   589072.40 5767300.00
   589035.50 5767343.50
   588953.70 5767436.50
   588901.10 5767513.50
   588876.10 5767549.50
   588821.90 5767601.50
   588713.30 5767674.50
   588580.40 5767747.50
   588485.10 5767818.00
   588401.10 5767834.50
   588336.30 5767896.50
   588299.30 5767925.50
   588256.90 5767959.00
   588178.80 5768026.00
   588147.70 5768118.50
   588140.10 5768149.00
   588203.30 5768313.00
99999
p output_test_tri 
   670888.60 5728493.50
   671006.40 5728529.50
   671159.30 5728521.00
   671310.40 5728501.00
   671458.20 5728447.50
   671529.10 5728340.50
   671597.40 5728239.00
   671680.70 5728093.50
   671748.70 5727980.50
   671726.80 5727764.50
   671713.00 5727554.00
   671677.80 5727338.50
   671535.30 5727202.50
   671406.30 5727077.50
   671294.20 5726935.50
   671166.70 5726883.00
   671006.40 5726908.50
   670816.70 5726990.50
   670701.10 5727059.50
   670563.60 5727156.50
   670448.80 5727325.50
   670426.40 5727459.50
   670430.30 5727642.50
   670466.10 5727886.00
   670490.10 5728013.00
   670558.20 5728150.50
   670621.60 5728254.50
   670755.10 5728401.50
   670888.60 5728493.50
99999

I have created a script, but this script can not cover my purpose. Kindly need your advice...

Code:
#!/bin/bash
## by ipatah
 
echo "Input_XY_File = "
read InputFile
echo "Culture Name = "
read CultureName
touch $CultureName.dat
echo "Cartograpic data in user defined format" >> $CultureName.dat
echo "....V....1....V....2....V....3....V....4....V....5....V....6....V....7" >> $CultureName.dat
echo "p $CultureName " >> $CultureName.dat
awk '{printf("%12.2f%14.2f\n",$1,$2)}' $InputFile >> $CultureName.dat
awk '{if(NR == 1) printf("%12.2f%14.2f\n",$1,$2)}' $InputFile >> $CultureName.dat
echo "99999" >> $CultureName.dat


Last edited by Scott; 11-13-2012 at 12:41 PM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. 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

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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

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

10. 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
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy