The UNIX and Linux Forums  


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
compare XML/flat file with UNIX file system structure shafi2all High Level Programming 6 08-15-2008 03:15 AM
Awk to convert a flat file to CSV file rkumudha Shell Programming and Scripting 14 07-17-2008 10:48 PM
match string in a file to file in a directory Jae Shell Programming and Scripting 5 01-19-2008 01:11 AM
Remove 5th character from Field1 & Print Raynon Shell Programming and Scripting 9 12-14-2007 05:57 AM
Converting Pivot file to flat file vskr72 Shell Programming and Scripting 2 10-18-2005 05:41 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 02-01-2009
frankie_konin frankie_konin is offline VIP Member  
VIP Member
  
 

Join Date: Feb 2009
Posts: 12
Wink csv file to array, match field1, replace in flat file field1 to field2

Hello, i am bit stuck with making script for automatic procedure.

Case:

Two files. One is flat file, other is csv file.
csv file has two column/fields with comma delimited data.

Here is what i need (explained way)

CSV file:

field1 | field2
"hello","byebye"
"hello2","byebye2"
"hello3","byebye3"

Flat file has matching data:

"hello"
"hello2"
"hello3"

If found:
"hello"
"hello2"
"hello3"
..in flat file, then it must be replaced from csv file with FIELD2 according
to search match.

But i have to search "hello" from csv file field1 data with flat file together and if found match in
flat file, it must be replaced from csv file with field2 data.

I know i could split csv file to two files, one containing field1 data and
second file field2 data but that would be not so dynamic way.
Though then i could easily use loop with cat + sed

Idea is to make nagios mass updating hosts naming changes in config.
So im wondering could i do it with awk or sed more universal way?

Any examples would be great help.

Thanks in advance..

Frankie

Last edited by frankie_konin; 02-01-2009 at 06:21 PM..
 

Bookmarks

Tags
host_name, nagios, update

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 09:50 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