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
Perl config file Help Harikrishna Shell Programming and Scripting 6 05-20-2008 04:51 AM
Copy data and send it to other file, with diff config single Shell Programming and Scripting 0 01-29-2008 09:56 AM
Extracting data from text file based on configuration set in config file suparnbector Shell Programming and Scripting 3 08-10-2007 02:25 AM
Using loop reading a file,retrieving data from data base. Sonu4lov Shell Programming and Scripting 1 01-19-2007 03:38 AM
using config file mape Shell Programming and Scripting 1 09-07-2006 01:37 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
  #1 (permalink)  
Old 11-18-2005
esham's Avatar
esham esham is offline
Registered User
  
 

Join Date: Nov 2004
Location: INDIA
Posts: 107
getting data from config file

pls help..

I need to get the ESSID value for athx

this is the config file..
pls help
Quote:
[ath0]
ESSID=open
MODE=managed
[ath1]
ESSID=wep
MODE=wep
  #2 (permalink)  
Old 11-18-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Try this.

Code:
[~/temp]$ cat esham.txt 
[ath0]
ESSID=open
MODE=managed
[ath1]
ESSID=wep
MODE=wep
Code:
[~/temp]$ cat esham.ksh 
#! /bin/ksh

sed -n -e '/\[ath[0-9]\]/{
N
s#ESSID=\(.*\)#\1#p
}' esham.txt
Code:
[~/temp]$ ./esham.ksh
[ath0]
open
[ath1]
wep
[~/temp]$
vino
  #3 (permalink)  
Old 11-18-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Better yet...

Code:
[~/temp]$ cat esham.ksh 
#! /bin/ksh

sed -n -e '/\[ath[0-9]\]/{
N
s#.*\(ath[0-9]\).*\nESSID=\(.*\)#\1=\2#p
}' esham.txt
Code:
[~/temp]$ ./esham.ksh 
ath0=open
ath1=wep
  #4 (permalink)  
Old 11-19-2005
esham's Avatar
esham esham is offline
Registered User
  
 

Join Date: Nov 2004
Location: INDIA
Posts: 107
can you please explain the usage, how sed is used here.

hope posetive answering
esham
  #5 (permalink)  
Old 11-19-2005
esham's Avatar
esham esham is offline
Registered User
  
 

Join Date: Nov 2004
Location: INDIA
Posts: 107
sorry, there is one problem...

the file may have some interfaces like eth0 or ath0..

ie, my file looks like this
Quote:
[ath0]
ESSID=open
MODE=managed
[xyz]
ESSID=shared
MODE=adhoc
[rfg]
ESSID=wepopen
MODE=wep_open
please change the sed arguments according to this..
thanks for ur help
  #6 (permalink)  
Old 11-20-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Your sed statement should now be

Code:
sed -n -e '/^\[.*]/{
N
s#^\[\(.*\)\]\nESSID=\(.*\)#\1=\2#p
}' esham.txt
Read it as:

- for any line starting with [ followed by some combination of characters and then a closing ]
- append the next line into the pattern space
- For the two lines that are present in the pattern space, collect the interfaces and its value and print it.
- Read the entries from esham.txt
Closed Thread

Bookmarks

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 06:11 AM.


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