Results 1 to 2 of 2
Can someone help me write a script that would filter out contents of a text file than save it? Here is a portion of my text file called 'fsd.txt' i ...
- 03-12-2008 #1Just Joined!
- Join Date
- Mar 2008
- Location
- Iowa
- Posts
- 4
Filter a text file
Can someone help me write a script that would filter out contents of a text file than save it? Here is a portion of my text file called 'fsd.txt' i want to filter....
Feature[ id=0 , geom=POLYGON ((-93.23087173555291 45.027015173947376, -93.23529330143086 45.031134906254515, -93.22526966748222 45.03663921971941, -93.22071442799766 45.032394248858154, -93.23087173555291 45.027015173947376)) , value=0.0 , colorIndex=8 ]
what i want to do is filter out everything and just keep one set of lat/lon & the value so something like this, -93.23087173555291 45.027015173947376 value=0
is there any way to do this and run a script? hope this made sense as i'm new to linux...thanks!
- 03-12-2008 #2
Welcome to the forums!
What you want is perfectly possible, but you do need to be able to predict where the info you want is... either by place, relation or pattern.
For example:
Every line with the word POLYGON has the data behind the second '(' in what are basically two space separated columns.
You may want to read up on:
cat, grep, cut, sed, awk, which ship with all distro's. You might also be interested in Perl.
Saving output to a file is as easy as redirecting output. A quick&easy example:
outputs all lines containing patternCode:cat file | grep pattern
stores all lines containing pattern in newfile (overwrites all data in newfile if any)Code:cat file | grep pattern > newfile
appends all lines containing pattern in newfile below the existing data, if anyCode:cat file | grep pattern >> newfile
___
You could also be more direct
but I feel that tends to get confusing if you add multiple layers of variables and filters.Code:grep pattern file >> newfile
Can't tell an OS by it's GUI


Reply With Quote