Computing.Net > Forums > Unix > Extracting characters from a field

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extracting characters from a field

Reply to Message Icon

Name: Miketheninja
Date: April 14, 2005 at 09:23:30 Pacific
OS: xp
CPU/Ram: inconsequential
Comment:

I have a large database and I am trying to pull certain portions of a field out of it and display that in its own file.

Basically I have a field that contains e-mail received line headers. I want to take that field and pull only the IP address contained in that received line out and display it in another file. I have been told that sed and grep are what I should be looking at rather than awk, the problem is that I have very limited knowledge of Unix. the field that i am trying to extract the IP addresses from is in the 3rd column under the name "value." If anyone can tell me what i should be looking at in Unix books to figure out how to accomplish this or help me out in any way i would really appreciate it.



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: April 14, 2005 at 14:23:34 Pacific
Reply:

For starters you're going to have to give more details - like what database you're using.

Once the database is known somebody should be able to help you execute a select:

select value from table_name

Then you have to tell us if the IP address is in value or if we have to parse value for the address.


0

Response Number 2
Name: Luke Chi
Date: April 17, 2005 at 15:37:49 Pacific
Reply:

cut -d " " -f3 $DB_OUTPUT_FILE

-d " " specifies that the delimiter of columns is one space
-f3 means that I want the third column

You don't have to dump the data from the DB. Are you using Oracle ? Using substr and instr Oracle functions in Oracle SQL, you'll be able to get IP directly from your table.

Luke Chi


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Extracting characters from a field

Extracting information from a file www.computing.net/answers/unix/extracting-information-from-a-file/7770.html

extracting few characters from file www.computing.net/answers/unix/extracting-few-characters-from-file/7991.html

Extracting numbers from a string www.computing.net/answers/unix/extracting-numbers-from-a-string/6459.html