analyzing list with street addresses


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers analyzing list with street addresses
# 1  
Old 02-10-2011
analyzing list with street addresses

Hi List,

Could someone please point me into the right direction with the following:

I have a file containing a list of street addresses.

I need to sort all the street addresses with the same number to a new file containing the street name and corresponding number.

So:
Code:
Strawinskylaan 1 > Strawinsky_1.txt
Strawinskylaan 2 > Strawinsky_2.txt
etc. etc.

I was thinking about something like this
Code:
a=0

for line in FiLENAME.txt
grep -A 1 "[$a]\{1,2\}\b" FILENAME.txt > "filename_$A.txt" 
a+=1

Any tip is much appreciated!

Thanks,

Martijn
(osX 10.6.5, bash)

Here's a short example of the file formatting:
Code:
Maatschap WTC Amsterdam E-Toren                                  *
Strawinskylaan 1, 1077XW Amsterdam                               

Maatschap WTC Amsterdam Zuidplein Hoog- en Laagbouw              *
Strawinskylaan 1, 1077XW Amsterdam                               

Maatschap WTC Amsterdam Zuidplein                                *
Strawinskylaan 2, 1077XW Amsterdam                               

Maatschap World Trade Center Amsterdam                           *
Strawinskylaan 3, 1077XW Amsterdam                               

H. Sligte Holding B.V.                                           *
Strawinskylaan 3, 1077XW Amsterdam


Last edited by Franklin52; 02-10-2011 at 04:44 PM.. Reason: Please use code tags, thank you
# 2  
Old 02-10-2011
Code:
awk -F ",| " '/Strawinskylaan/{print >"Strawinsky_"$2".txt"}' file

# 3  
Old 02-10-2011
Hi Yintuemi,
thanks for the reply, and pointing me towards awk instead of using grep.
unfortunately it returns an error..

awk: illegal statement at source line 1

Might this be difference in shell?

---------- Post updated at 11:08 PM ---------- Previous update was at 11:04 PM ----------

solved it already...
# 4  
Old 02-10-2011
it works fine in my computer,
Is the results what you want?

Code:
 awk -F ",| " '/Strawinskylaan/{print >"Strawinsky_"$2".txt"}' file
ls *.txt
Strawinsky_1.txt  Strawinsky_2.txt  Strawinsky_3.txt
cat Strawinsky_1.txt
Strawinskylaan 1, 1077XW Amsterdam
Strawinskylaan 1, 1077XW Amsterdam
cat Strawinsky_2.txt
Strawinskylaan 2, 1077XW Amsterdam
cat Strawinsky_3.txt
Strawinskylaan 3, 1077XW Amsterdam
Strawinskylaan 3, 1077XW Amsterdam

Y
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

List Contacted Web Addresses?

Greetings. I'm in the process of tracking down an issue with Firefox, and need some way of gathering the actual web addresses which are connected to from localhost. The specific problem centers around the determination/capture of the exact generated app.update.url address formed by the... (2 Replies)
Discussion started by: LinQ
2 Replies

2. Shell Programming and Scripting

Formatting list of IP addresses into a grep command

Hi I have an input file with a list of random IP addresses, each on a new line. Below is just an example as I omitted the real IP addresses for obvious reasons. Input: random_ip.txt 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1... (7 Replies)
Discussion started by: lewk
7 Replies

3. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

4. Shell Programming and Scripting

Extract list of IP addresses from a text file.

I have an xml file with IP addresses all over the show. I want to print only the IP addresses and cut off any text before or after the IP address. Example: Note: The IP addresses (x.x.x.x) do not consistently appear in the xml file as per the pattern below. Sometimes there are text before... (8 Replies)
Discussion started by: lewk
8 Replies

5. Solaris

Command to list all the VIP addresses assigned to Solaris server

Hello All, I want to list all the VIP addresses assigned to Solaris server. whats the command we have use on solaris for this? Please help Thanks!! Weblogic Consultant (1 Reply)
Discussion started by: weblogicsupport
1 Replies

6. UNIX Desktop Questions & Answers

Using Mailx to send to list of email addresses

Im trying to use a shell script to send to a list of email addresses in a txt file. Here is what i have tried but it keeps sending to dead.letter... Success.ksh contains... mailx -s"Night Batch Success" 'cat /Scripts/email_addresses.txt' < /Scripts/email_body_message.txt The email body... (1 Reply)
Discussion started by: aguad3
1 Replies

7. UNIX for Dummies Questions & Answers

Help extracting MAC addresses from List

Hello all. I have a large number of text files outputted from various Netstumbler Wireless Scans; from which I need to extract the MAC addresses of the various Access Points. The Text files look like this: # $Creator: Network Stumbler Version 0.4.0 # $Format: wi-scan summary with... (9 Replies)
Discussion started by: dhs23
9 Replies
Login or Register to Ask a Question