<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/index.php?action=history&amp;feed=atom&amp;title=GNU_text_tools</id>
	<title>GNU text tools - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/index.php?action=history&amp;feed=atom&amp;title=GNU_text_tools"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GNU_text_tools&amp;action=history"/>
	<updated>2026-04-18T17:10:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GNU_text_tools&amp;diff=8787&amp;oldid=prev</id>
		<title>Neteler: + external links</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GNU_text_tools&amp;diff=8787&amp;oldid=prev"/>
		<updated>2009-05-12T09:06:37Z</updated>

		<summary type="html">&lt;p&gt;+ external links&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 09:06, 12 May 2009&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l140&quot;&gt;Line 140:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 140:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;pages.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;pages.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;== See also ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [http://tldp.org/LDP/abs/html/textproc.html Text Processing Commands]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* [http://www.gnu.org/software/coreutils/manual/html_node/index.html GNU Coreutils]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Documentation]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category: FAQ]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category: FAQ]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Neteler</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GNU_text_tools&amp;diff=4486&amp;oldid=prev</id>
		<title>Neteler: Using GNU text tools for GIS data preparation</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GNU_text_tools&amp;diff=4486&amp;oldid=prev"/>
		<updated>2007-07-21T12:10:32Z</updated>

		<summary type="html">&lt;p&gt;Using GNU text tools for GIS data preparation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;'''Using GNU text tools for GIS data preparation'''&lt;br /&gt;
&lt;br /&gt;
The GNU text tools cat, cut, join, head, more, paste, sed and tail and the&lt;br /&gt;
awk (&amp;quot;pattern scanning and processing language&amp;quot;) provide a range of possibilities&lt;br /&gt;
to modify ASCII texts and tables. Often attribute tables are delivered&lt;br /&gt;
in ASCII formats such as CSV (Comma Separated Values format) or blank&lt;br /&gt;
delimited text. Especially in scripts the tools introduced here are quite helpful&lt;br /&gt;
to automate text formatting.&lt;br /&gt;
Here we show modifications of the Spearfish soils map&lt;br /&gt;
legend which is available at GRASS Web site and already included in the&lt;br /&gt;
Spearfish sample data set (see&lt;br /&gt;
/usr/local/share/grassdata/spearfish/soils_legend.txt). This legend is&lt;br /&gt;
an ASCII table, which contains further attributes for the soils map. We want&lt;br /&gt;
to show how to modify this table to a reclass rules file applicable to v.reclass&lt;br /&gt;
and r.reclass. First let's have a look into the file:&lt;br /&gt;
&lt;br /&gt;
     more soils_legend.txt&lt;br /&gt;
&lt;br /&gt;
Within the more program continue to a next page with &amp;lt;SPACE&amp;gt;, quit with&lt;br /&gt;
&amp;lt;q&amp;gt;, search for a phrase with &amp;lt;/&amp;gt;. Above file may look like this:&lt;br /&gt;
&lt;br /&gt;
     0:no data:&lt;br /&gt;
     1:AaB:Alice fine sandy loam, 0 to 6&lt;br /&gt;
     2:Ba:Barnum silt loam&lt;br /&gt;
     3:Bb:Barnum silt loam, channeled&lt;br /&gt;
     4:BcB:Boneek silt loam, 2 to 6&lt;br /&gt;
     5:BcC:Boneek silt loam, 6 to 9&lt;br /&gt;
     6:BeE:Butche stony loam, 6 to 50&lt;br /&gt;
     [...]&lt;br /&gt;
&lt;br /&gt;
The legend columns are separated by &amp;quot;:&amp;quot;. In the first column the category&lt;br /&gt;
numbers (attribute IDs) are stored. In the second column the first letter always&lt;br /&gt;
capital is the initial letter of the soil name. The second letter is a capital if&lt;br /&gt;
the mapping unit is broadly defined; otherwise, it is a small letter. The third&lt;br /&gt;
letter, always a capital, A, B, C, D, E or F, indicates the slope. Symbols&lt;br /&gt;
without slope letter are those of mapping units that do not have slope as part&lt;br /&gt;
of the name. In the third column the full name of the soil is written along&lt;br /&gt;
with the typical slope.&lt;br /&gt;
&lt;br /&gt;
First we want to reduce the legend to attribute ID, soil name initials and&lt;br /&gt;
text attribute without the slope information (this may go into another table&lt;br /&gt;
or derived from the Spearfish elevation.dem). Note that we proceed step-bystep&lt;br /&gt;
although you can also compose the commands to a few (or even a single)&lt;br /&gt;
lines. The cut tool cuts column-wise depending on the specified delimiter. We&lt;br /&gt;
specify delimiter : and select the first column (with field parameter f), then&lt;br /&gt;
pipe the result into a new file:&lt;br /&gt;
&lt;br /&gt;
     cut -d',' -f1 soils_legend.txt &amp;gt; soils_legend2.txt&lt;br /&gt;
&lt;br /&gt;
Checking the new file with more shows us:&lt;br /&gt;
&lt;br /&gt;
     0:no data:&lt;br /&gt;
     1:AaB:Alice fine sandy loam&lt;br /&gt;
     2:Ba:Barnum silt loam&lt;br /&gt;
     3:Bb:Barnum silt loam&lt;br /&gt;
     4:BcB:Boneek silt loam&lt;br /&gt;
     5:BcC:Boneek silt loam&lt;br /&gt;
     6:BeE:Butche stony loam&lt;br /&gt;
     [...]&lt;br /&gt;
&lt;br /&gt;
Starting from the new file we will select only the text label:&lt;br /&gt;
&lt;br /&gt;
     cut -d':' -f3 soils_legend2.txt &amp;gt; soils_legendlabels.txt&lt;br /&gt;
&lt;br /&gt;
Checking the new file with more shows us:&lt;br /&gt;
&lt;br /&gt;
     Alice fine sandy loam&lt;br /&gt;
     Barnum silt loam&lt;br /&gt;
     Barnum silt loam&lt;br /&gt;
     Boneek silt loam&lt;br /&gt;
     Boneek silt loam&lt;br /&gt;
     Butche stony loam&lt;br /&gt;
     [...]&lt;br /&gt;
&lt;br /&gt;
Note that the first line is empty since the no-data field doesn't contain a text&lt;br /&gt;
label. Alternatively you can compose above steps to one command:&lt;br /&gt;
&lt;br /&gt;
     cut -d',' -f1 soils_legend.txt | cut -d':' -f3 &amp;gt; soils_legendlabels.txt&lt;br /&gt;
&lt;br /&gt;
Now further hints: In case you want to cut a column at a specific position,&lt;br /&gt;
you can use the -b flag:&lt;br /&gt;
&lt;br /&gt;
     cut -b1,2 soils_legend.txt&lt;br /&gt;
     0:n&lt;br /&gt;
     1:A&lt;br /&gt;
     2:B&lt;br /&gt;
     3:B&lt;br /&gt;
     4:B&lt;br /&gt;
     5:B&lt;br /&gt;
     6:B&lt;br /&gt;
     [...]&lt;br /&gt;
&lt;br /&gt;
If you want to see only the first lines of a file, use head. The number of lines&lt;br /&gt;
to be displayed has to be entered with a preceding minus character:&lt;br /&gt;
&lt;br /&gt;
     head -4 soils_legend.txt&lt;br /&gt;
&lt;br /&gt;
The result looks as follows:&lt;br /&gt;
&lt;br /&gt;
     0:no data:&lt;br /&gt;
     1:AaB:Alice fine sandy loam, 0 to 6&lt;br /&gt;
     2:Ba:Barnum silt loam&lt;br /&gt;
     3:Bb:Barnum silt loam, channeled&lt;br /&gt;
&lt;br /&gt;
If you want to see only the last lines, use tail. It is used similar to head:&lt;br /&gt;
&lt;br /&gt;
     tail -3 soils_legend.txt&lt;br /&gt;
&lt;br /&gt;
leading to the output:&lt;br /&gt;
&lt;br /&gt;
     53:WaA:Weber loam, 0 to 2&lt;br /&gt;
     54:Wb:Winetti cobbly loam&lt;br /&gt;
     55:water&lt;br /&gt;
&lt;br /&gt;
Both may be combined to show a portion of the text file (here only lines 3 to 5):&lt;br /&gt;
&lt;br /&gt;
     head -5 soils_legend.txt | tail -3&lt;br /&gt;
&lt;br /&gt;
Here the head command shows the first five lines, the tail command the last&lt;br /&gt;
three of these five lines:&lt;br /&gt;
&lt;br /&gt;
     2:Ba:Barnum silt loam&lt;br /&gt;
     3:Bb:Barnum silt loam, channeled&lt;br /&gt;
     4:BcB:Boneek silt loam, 2 to 6&lt;br /&gt;
&lt;br /&gt;
In order to sequentially concatenate two files, use cat:&lt;br /&gt;
&lt;br /&gt;
     cat file1 file2 &amp;gt; file1and2&lt;br /&gt;
&lt;br /&gt;
If you need to paste two files column-wise, use paste. You can optionally&lt;br /&gt;
change the column delimiter from the default tabulator to another character.&lt;br /&gt;
The command join is allowing to work similar to a simple database management&lt;br /&gt;
system - it joins together ASCII tables according to unique column&lt;br /&gt;
entries.&lt;br /&gt;
&lt;br /&gt;
A powerful string editor is sed which allows to exchange, add or cut off&lt;br /&gt;
strings from text files by rule definitions.&lt;br /&gt;
With awk which we already used throughout the book, you can perform&lt;br /&gt;
calculations or formatted printing. For details please refer to the related manual&lt;br /&gt;
pages.&lt;br /&gt;
&lt;br /&gt;
[[Category: FAQ]]&lt;/div&gt;</summary>
		<author><name>Neteler</name></author>
	</entry>
</feed>