Sponsored Content
Top Forums Shell Programming and Scripting Shell scripting substitution techniques Post 302456222 by rich@ardz on Thursday 23rd of September 2010 03:59:54 PM
Old 09-23-2010
Shell scripting substitution techniques

Hi guys, I'm looking for some thoughts on this. I'm trying to do a clean 1 liner to substitute some values. What I have:

Code:
sed 's/Personid=.*/Personid=xxxxxx/' $tmpFileOut

Code:
sed 's/Person:.*/Person:xxxxxx/' $tmpFileOut

Code:
sed 's/PersonID:.*/PersonID: xxxxxx/' $tmpFileOut

Obviously that's a bit sucky, I'm repeating 3 lines which are all basically doing the same thing. I want to smarten it up. The thing they all have in common is that I'm looking for 'Person' and whatever is after that, and substituting it. Is there a cleaner way to do the above in one go?

Perl - I'm doing a substitution like this:

Code:
perl -pe 's/(?<![a-z])dog(?![a-z])/cat/g' $tmpFileOut

Code:
perl -pe 's/(?<![a-z])green(?![a-z])/blue/g' $tmpFileOut

again, I'm repeating lines - what's a cleaner way to do this in perl? I have like 15 lines of substitions, I'd like it short and sweet - what's the best way to do it? Put all substitions onto one line? how would I do that? or would some kind of array be the best way to do it?

Help/thoughts appreciated Smilie

Last edited by rich@ardz; 09-23-2010 at 05:01 PM.. Reason: code tags
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

2. Solaris

Shell variables substitution in a file

Hi, I have to read a file and translate the contents including substituting the variables if any and write to another file without using sed or awk. For ex:- inputfile.txt ----------- servername=$SERVER application=$APPL outputfile.txt ------------ servername=actual server name... (2 Replies)
Discussion started by: axes
2 Replies

3. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

4. Shell Programming and Scripting

Using C-Shell Scripting for Substitution

mv myFile.txt myFile.txt.bak sed s/foo/bar/g myFile.txt.bak > myFile.txt Turn the two-line version, above, of the substitution commands into a shell script, subst1 taking three parameters: the string to be replaced the string with which to replace it the name of the file in which to make the... (1 Reply)
Discussion started by: RogerW
1 Replies

5. Shell Programming and Scripting

Help with substitution in shell script

Hello, I Have a file like this, with five columns: B D F T L --------- 0 0 0 0 0 0 0 0 1 0 0 2 0 0 1 I need, for each row, to append another five columns similar to the first ones, but with the field labeled as "T" (4th field of the column) substituted in this way: (16 * value of... (3 Replies)
Discussion started by: PapaJustify
3 Replies

6. Shell Programming and Scripting

Escape and command substitution in scripting

I have one question in shell script for escape "\" with command substitution "` `". I post there to seek help to understand how it works. My original one piece of code in script like this: This piece of code in whole script is working without errors chk_mode=`sqlplus -s /nolog<<EOF connect /... (4 Replies)
Discussion started by: duke0001
4 Replies
Locale::Codes::LangFam(3)				User Contributed Perl Documentation				 Locale::Codes::LangFam(3)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.3 2013-02-27 Locale::Codes::LangFam(3)
All times are GMT -4. The time now is 12:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy