The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Validating XSL sheet data in Unix Data file ravijunghare UNIX for Dummies Questions & Answers 1 11-07-2008 09:32 AM
Need Help for Adding Three new columns in existing file from fatching data from file Sandeep_Malik Shell Programming and Scripting 36 09-17-2008 05:12 PM
Extracting data from text file based on configuration set in config file suparnbector Shell Programming and Scripting 3 08-10-2007 02:25 AM
Post Shell programming: Question about source a file and read data from the file ccwq Shell Programming and Scripting 3 08-04-2007 10:28 PM
Using loop reading a file,retrieving data from data base. Sonu4lov Shell Programming and Scripting 1 01-19-2007 03:38 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 12-04-2008
Christoph Spohr Christoph Spohr is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 205
@samshaw:

Perhaps you should open your own thread?

For a start try this:

Code:
HOSTS=( $(sed -n 's/^<hostAddress>\([^<]*\).*/\1/p' xfile) )
It will write the results of the sed command into an array HOSTS.

Code:
echo ${HOSTS[1]} etc.
Will give you the values.

Sed is best learned by example. There are many pages with sed one liners.
This one here does the following:

-n only print if asked to print a line
's/ substitute
^<host every line starting with host
\([^<]*\) every character except a "<" and save what you have found in "\1"
.* the rest of the line
/\1/ substitute by what we have just save in \1
p' print this line.

The command does two tasks at a time: a) it finds all lines starting with
host..., b) it extracts the value between the tags.

HTH Chris
  #9 (permalink)  
Old 12-04-2008
naughty21 naughty21 is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 16
Quote:
Originally Posted by dennis.jacob View Post
Try this quick approch:
Code:
sed 's/>/\n>/g' filename | sed 's/>\([A-Za-z0-9]*@[A-Za-z0-9]*\.[A-Za-z0-9]*\)<.*/\1/' | sed '/@/!d'
Is this works for ksh ? ... Im not getting any output
Sponsored Links
Closed Thread

Bookmarks

Tags
data, search, shell script, shell scripting, tag, unix scripting, unix scripting basics, xml

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0