LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 03-19-2007, 11:46 AM   #1
Critcho
LQ Newbie
 
Registered: Feb 2006
Posts: 20

Rep: Reputation: 0
translate from word list in a file


Is it possible to direct sed or tr to use a list of substitutions in a file? I realise that sed can pull a list of commands from a file, I am just trying to make it easier on the end user.

e.g.
Code:
'#MyVarName1' 'Logic.Values.Digital01'
'#MyVarName2' 'System.Stats.Resets.Count'
is a much easier file for the user to edit, instead of ...
Code:
s/'#MyVarName1'/'Logic.Values.Digital01'/g
s/'#MyVarName2'/'System.Stats.Resets.Count'/g
easier to read too...
 
Old 03-20-2007, 07:30 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
You can have a script that reads the file and then uses a "for" loop to put each consecutive item into a sed statement.

Even simpler is the -f option in sed, in which it reads its info from a file.

Here is my favorite sed tutorial: http://www.grymoire.com/Unix/Sed.html
 
  


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
LXer: OpenSource medical spelling word list released LXer Syndicated Linux News 0 02-22-2007 12:46 PM
The HorizSync key word must followed by a list of numbers or ranges comox *BSD 2 03-14-2005 03:57 AM
help... get single word from file night-blade1 Programming 3 10-12-2004 08:58 AM
file+word problems warney_out Programming 3 09-02-2004 05:32 AM
MS Word file converter? pepelaz Programming 2 12-13-2003 08:37 AM

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

All times are GMT -5. The time now is 07:46 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