Try this to print column 1 and 3. I think it will work on all of your files no matter how many spaces are in between:<br><br>cat file | awk '{print $1, $3}'<br><br>David<br><br><div><span class="gmail_quote">On 8/9/06, <b class="gmail_sendername">
maning sambale</b> &lt;<a href="mailto:emmanuel.sambale@gmail.com">emmanuel.sambale@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
David &amp; Kevin,<br><br>Yes, python or perl would be great.&nbsp;&nbsp;But what I need right now is a<br>quick (maybe dirty) approach.&nbsp;&nbsp;I do intend to study python as I've<br>heard a lot about it.&nbsp;&nbsp;But not this time, I'm trying to study Linux
<br>tools the &quot;modular way&quot;:)<br><br>Cheers,<br><br>Maning<br><br>On 8/8/06, Slover, Kevin &lt;<a href="mailto:kslover@dewberry.com">kslover@dewberry.com</a>&gt; wrote:<br>&gt; Maning,<br>&gt;&nbsp;&nbsp; As David says, python or perl are used now for manipulating text
<br>&gt; files.&nbsp;&nbsp;I have done several quick scripts for doing this with Perl<br>&gt; (thanks David for the python script, bout time I learn to use it).&nbsp;&nbsp;A<br>&gt; basic perl script would look like this (and note, my Perl is not great,
<br>&gt; and am sure there are many other ways to do this) :<br>&gt;<br>&gt; Explanation:&nbsp;&nbsp;Files.txt is a ls/dir listing of the wanted files to<br>&gt; combine.&nbsp;&nbsp;Then, the script reads in each file, stripping any sort of<br>
&gt; header information from the columns, and outputting everything into one<br>&gt; file.&nbsp;&nbsp;Fairly simple, and a quick search on the web for file<br>&gt; manipulation using Perl will come up with probably a better explanation.
<br>&gt;<br>&gt; $in_file = &quot;Files.txt&quot;;<br>&gt; $out_file = &quot;outfile.txt&quot;;<br>&gt;<br>&gt; open (INFILE, $in_file) || die &quot;INFILE&quot;;<br>&gt; open (OUTFILE, &quot;&gt;$out_file&quot;) || die &quot;OUTFILE&quot;;
<br>&gt;<br>&gt; @infiles = &lt;INFILE&gt;;<br>&gt; close(INFILE);<br>&gt;<br>&gt; print OUTFILE &quot;z,x,y\n&quot;;<br>&gt;<br>&gt; foreach $in_files (@infiles)<br>&gt; {<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; open (INFILE1, $in_files) || die &quot;Cannot open $in_files&quot;;
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (&lt;INFILE1&gt;)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chomp($_);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ($x, $y, $z) = split ',',$_;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($x != x) {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print OUTFILE &quot;$z,$x,$y\n&quot;; }
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; close(INFILE1);<br>&gt; }<br>&gt;<br>&gt; close(OUTFILE);<br>&gt;<br>&gt;<br>&gt; Kevin Slover<br>&gt; Coastal / GIS Specialist<br>&gt; 2872 Woodcock Blvd Suite 230<br>&gt; Atlanta GA 30341
<br>&gt; (P) 678-530-0022<br>&gt; (F) 678-530-0044<br>&gt;<br>&gt; -----Original Message-----<br>&gt; From: <a href="mailto:grassuser-bounces@grass.itc.it">grassuser-bounces@grass.itc.it</a><br>&gt; [mailto:<a href="mailto:grassuser-bounces@grass.itc.it">
grassuser-bounces@grass.itc.it</a>] On Behalf Of maning sambale<br>&gt; Sent: Tuesday, August 08, 2006 12:12 AM<br>&gt; To: <a href="mailto:grassuser@grass.itc.it">grassuser@grass.itc.it</a><br>&gt; Subject: [GRASS-user] combine &amp; edit multiple text files
<br>&gt;<br>&gt; Hi!<br>&gt;<br>&gt; I have a number of ascii files downloaded from ASTR fire project from<br>&gt; the ESA Ionia showing monthly fire incidences from 1996-2006.&nbsp;&nbsp;I<br>&gt; intend to combine all these files, remove unwanted columns and get the
<br>&gt; records from my current region/study area only. All records combined<br>&gt; is 929,155 records!&nbsp;&nbsp;My guess is I need to use the cat, cut, awk<br>&gt; commands.<br>&gt;<br>&gt; Challenge: the files have different record formating
<br>&gt;<br>&gt; file 1 is like this (take note of the space as the delimiter):<br>&gt;<br>&gt; Date&nbsp;&nbsp; Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lon&nbsp;&nbsp;&nbsp;&nbsp; NDVI&nbsp;&nbsp;Station<br>&gt; 020201 032428.163&nbsp;&nbsp;-38.379&nbsp;&nbsp;-66.334 -.-- ESR<br>&gt; 020201 032428.163
&nbsp;&nbsp;-38.375&nbsp;&nbsp;-66.323 -.-- ESR<br>&gt; 020201 032428.312&nbsp;&nbsp;-38.378&nbsp;&nbsp;-66.359 -.-- ESR<br>&gt; 020201 032428.312&nbsp;&nbsp;-38.374&nbsp;&nbsp;-66.348 -.-- ESR<br>&gt; 020201 032428.312&nbsp;&nbsp;-38.371&nbsp;&nbsp;-66.337 -.-- ESR<br>&gt;<br>&gt; file 2 looks like this:
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Orbit&nbsp;&nbsp;Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Lon<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4384&nbsp;&nbsp;&nbsp;&nbsp; 81704.016&nbsp;&nbsp;&nbsp;&nbsp;19.364&nbsp;&nbsp;-155.103<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4384&nbsp;&nbsp;&nbsp;&nbsp; 81704.164&nbsp;&nbsp;&nbsp;&nbsp;19.373&nbsp;&nbsp;-155.105<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4384&nbsp;&nbsp;&nbsp;&nbsp; 
81704.164&nbsp;&nbsp;&nbsp;&nbsp;19.375&nbsp;&nbsp;-155.096<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4385&nbsp;&nbsp;&nbsp;&nbsp;100833.648&nbsp;&nbsp;&nbsp;&nbsp;56.638&nbsp;&nbsp; 161.281<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4386&nbsp;&nbsp;&nbsp;&nbsp;130756.352&nbsp;&nbsp; -20.340&nbsp;&nbsp; 134.099<br>&gt;<br>&gt; I only need the columns for date, time, lat, lon
<br>&gt;<br>&gt; Here's what I did:<br>&gt;<br>&gt; #combine all file (monthly)<br>&gt; cat 9904ESA01.FIRE 9905ESA01.FIRE 9906ESA01.FIRE 9907ESA01.FIRE<br>&gt; 9908ESA01.FIRE ... &gt; test<br>&gt;<br>&gt; # cut only desired columns (1_4) delimeiter is spac ' '
<br>&gt; cut -d' ' -f1 test &gt; 1<br>&gt; cut -d' ' -f2 test &gt; 2<br>&gt; cut -d' ' -f3 test &gt; 3<br>&gt; cut -d' ' -f4 test &gt; 4<br>&gt;<br>&gt; # combine all columns<br>&gt; paste 1 2 3 4 &gt; test5<br>&gt;<br>&gt; example output:
<br>&gt;<br>&gt; 021231 223941.761&nbsp;&nbsp; 11.035&nbsp;&nbsp; -5.016 -.-- ESR<br>&gt; 021231 224005.303&nbsp;&nbsp; 12.226&nbsp;&nbsp; -6.243 -.-- ESR<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4380&nbsp;&nbsp;&nbsp;&nbsp; 25934.057&nbsp;&nbsp; -37.022&nbsp;&nbsp; -69.589<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 20030101&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4382&nbsp;&nbsp;&nbsp;&nbsp; 45951.090
&nbsp;&nbsp;&nbsp;&nbsp;33.005&nbsp;&nbsp;-110.772<br>&gt;<br>&gt; The problem is for the file example 1, lat and lon columns contain<br>&gt; spaces other than the delimiter example &quot; -38.00&quot; while another is<br>&gt; &quot;120.00&quot;&nbsp;&nbsp;In the file2 example, more spaces are there.&nbsp;&nbsp;I think I need
<br>&gt; to process different file formats separately but how do I solve the<br>&gt; problem for spaces in the lat/lon columns?<br>&gt;<br>&gt; One last question how do I get the records for my current region only?<br>&gt;
<br>&gt; north:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20:00:01.49976N<br>&gt; south:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5:00:01.499767N<br>&gt; west:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 115:00:01.5012E<br>&gt; east:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 130:00:01.501193E<br>&gt;<br>&gt;<br>&gt; I'm starting to understand awk (reading the gawk manual right now) but
<br>&gt; may take a while to get do something magical.<br>&gt;<br>&gt; Thanks!<br>&gt;<br>&gt; Maning<br>&gt;<br>&gt; --<br>&gt; |---------|----------------------------------------------------------|<br>&gt; | __.-._&nbsp;&nbsp;|&quot;Ohhh. Great warrior. Wars not make one great.&quot; -Yoda&nbsp;&nbsp;&nbsp;&nbsp; |
<br>&gt; | '-._&quot;7' |&quot;Freedom is still the most radical idea of all&quot; -N.Branden|<br>&gt; |&nbsp;&nbsp;/'.-c&nbsp;&nbsp;|Linux registered user #402901, <a href="http://counter.li.org/">http://counter.li.org/</a>&nbsp;&nbsp;&nbsp;&nbsp; |<br>&gt; |&nbsp;&nbsp;|&nbsp;&nbsp;/T&nbsp;&nbsp;|http://esambale.wikispaces.com|
<br>&gt; | _)_/LI<br>&gt; |http://www.geocities.com/esambale/philbiodivmap/philbirds.html&nbsp;&nbsp; |<br>&gt; |---------|----------------------------------------------------------|<br>&gt;<br>&gt; _______________________________________________
<br>&gt; grassuser mailing list<br>&gt; <a href="mailto:grassuser@grass.itc.it">grassuser@grass.itc.it</a><br>&gt; <a href="http://grass.itc.it/mailman/listinfo/grassuser">http://grass.itc.it/mailman/listinfo/grassuser</a>
<br>&gt;<br>&gt;<br><br><br>--<br>|---------|----------------------------------------------------------|<br>| __.-._&nbsp;&nbsp;|&quot;Ohhh. Great warrior. Wars not make one great.&quot; -Yoda&nbsp;&nbsp;&nbsp;&nbsp; |<br>| '-._&quot;7' |&quot;Freedom is still the most radical idea of all&quot; -
N.Branden|<br>|&nbsp;&nbsp;/'.-c&nbsp;&nbsp;|Linux registered user #402901, <a href="http://counter.li.org/">http://counter.li.org/</a>&nbsp;&nbsp;&nbsp;&nbsp; |<br>|&nbsp;&nbsp;|&nbsp;&nbsp;/T&nbsp;&nbsp;|http://esambale.wikispaces.com|<br>| _)_/LI&nbsp;&nbsp;|http://www.geocities.com/esambale/philbiodivmap/philbirds.html&nbsp;&nbsp; |
<br>|---------|----------------------------------------------------------|<br><br>_______________________________________________<br>grassuser mailing list<br><a href="mailto:grassuser@grass.itc.it">grassuser@grass.itc.it
</a><br><a href="http://grass.itc.it/mailman/listinfo/grassuser">http://grass.itc.it/mailman/listinfo/grassuser</a><br></blockquote></div><br><br clear="all"><br>-- <br>David Finlayson