LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-16-2012, 03:48 AM   #1
di80
LQ Newbie
 
Registered: Oct 2011
Posts: 4

Rep: Reputation: Disabled
grep -o and strange character


hi,
i have googled around this but didn`t find any solution. I am trying to get some coordinates from a website using grep. Copied html source from a website to a txt file and i grep this file with

Code:
grep -o "(-?[0-9]{2,3}\.[0-9]+), -?([0-9]){2,3}\.([0-9])+" baltimore.txt
the result printed on terminal is as expected,well formed long/lat coordinates, but when i redirect output to a csv or txt file i get this

Code:
39.29234400000	 -76.57470350000
39.31975300000	 -76.61237900000
39.31537620000	 -76.61709370000
39.33807260000	 -76.60753880000
39.35307750000	 -76.70132740000


the website is this

can anyone explain why do these characters come up and how can i get rid of them when i redirect output to a file?
 
Old 10-16-2012, 05:23 AM   #2
zQUEz
Member
 
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 54
my first thought is maybe a dos2unix issue. Try doing `dos2unix baltimore.txt` and then rerunning and see if that works.
The link you provided works, but brings up a default page so I don't know where you are getting the lat/log figures from to test myself.
 
Old 10-16-2012, 05:50 AM   #3
di80
LQ Newbie
 
Registered: Oct 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by zQUEz View Post
my first thought is maybe a dos2unix issue. Try doing `dos2unix baltimore.txt` and then rerunning and see if that works.
The link you provided works, but brings up a default page so I don't know where you are getting the lat/log figures from to test myself.
hi thanks for the reply. I tried dos2unix but didnt change anything...
yes actually you need to select something from the dropdown menus, say "Time Frame" -> Past 30 Days and the "show results"...Then right click outside the map and select View source...there you can find the coordinates. i think they are in a js array.
 
Old 10-16-2012, 06:11 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Those look like ANSI colour codes, maybe you have grep set to highlight always? Try
Code:
grep --color=never -o "(-?[0-9]{2,3}\.[0-9]+), -?([0-9]){2,3}\.([0-9])+" baltimore.txt
 
1 members found this post helpful.
Old 10-16-2012, 06:19 AM   #5
di80
LQ Newbie
 
Registered: Oct 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ntubski View Post
Those look like ANSI colour codes, maybe you have grep set to highlight always? Try
Code:
grep --color=never -o "(-?[0-9]{2,3}\.[0-9]+), -?([0-9]){2,3}\.([0-9])+" baltimore.txt
yes i have an alias

thanks!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove first character with sed and grep r_jr Programming 11 02-04-2012 03:37 AM
[SOLVED] Number of backslash character to use in grep luvshines Programming 12 10-03-2011 11:57 PM
[SOLVED] Using grep with the accent character present eddyq Linux - Newbie 4 07-08-2011 04:46 PM
[SOLVED] special character in string variable and grep ted_chou12 Linux - Newbie 4 04-11-2011 07:59 AM
[SOLVED] Grep until certain character or pattern appears ohijames Programming 7 06-28-2010 08:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration