Sponsored Content
Full Discussion: Mapped list replacement
Top Forums Shell Programming and Scripting Mapped list replacement Post 302244755 by treesloth on Wednesday 8th of October 2008 02:48:43 PM
Old 10-08-2008
Mapped list replacement

Hi to all. I've looked for this, and haven't found it, but please pardon me if I've overlooked something. I'm trying to come up with a relatively simple command line search and replace from and to which I can easily pipe. In particular, let's suppose there are 2 lists, A and B. If a string appears on list A, replace it with its corresponding member on list B. For example, let's replace heroes with villains:

ListA,ListB
Superman,Lex_Luthor
Batman,The_Joker
ProfessorX,Magneto

So, anywhere 'Superman' appears, replace him with 'Lex_Luthor' and so on. So, in a perfect world, 'tr' might be expanded to do this. This doesn't work, of course, so please treat this as pseudocode:

Code:
tr 'Superman,Batman,ProfessorX' 'Lex_Luthor,The_Joker,Magneto'

Something that actually does work is:

Code:
 sed -e 's/Superman/Lex_Luthor/' -e 's/Batman/The_Joker/' -e 's/ProfessorX/Magneto/'

That works, and is an acceptable solution, but will grow pretty quickly with additional terms. Is there a more compact way of accomplishing this? Many thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Linux

How to access mapped dirve in Linux

i want to access mounted/mapped drive in linux using C code is it possible to access the mapped drive in linux using C code ? waiting for replay NIrav (0 Replies)
Discussion started by: niravuchat
0 Replies

2. Filesystems, Disks and Memory

Virtual Machine and Mapped Raw LUN's

Hello, I have a server running CentOS 5.1 on a virtual machine. Right now, there is one virtual disk on the system. Below are the result when I run the df commmand: Filesystem.....1K-blocks.........Used.....Available....Use%.....Mounted on... (1 Reply)
Discussion started by: kennyw1000
1 Replies

3. SCO

SCO Mapped Drive

We are running SCO OpenServer 5.0.7. Some of my users have drives mapped to the SCO box, some don't. The consultant, who setup the mapped drives, is long gone, and I need more users to have drive letter mapping. When I try to map a drive via windows, I am repeatedly asked for a user/password,... (1 Reply)
Discussion started by: bnhcomputing
1 Replies

4. UNIX for Advanced & Expert Users

Linux: Access time of mapped data

Before I forget, I'm running on a RedHat 5 box with the following uname -a output: Linux gnc141c 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:19 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux Now on to my question. I'm using a tool that maps a Matlab .mat file using the Linux mmap functionality and then... (1 Reply)
Discussion started by: rusttree
1 Replies

5. Programming

segmantation Fault error SEGV_MAPERR - Address not mapped to object

Program received signal SIGSEGV, Segmentation fault si_code: 1 - SEGV_MAPERR - Address not mapped to object. 0x9fffffffbe7080d0:0 in free+0xb0 () from /usr/lib/hpux64/libc.so.1 Hi , I have developed a class to read config file (flat file with space as a field seperator ) on plattform... (3 Replies)
Discussion started by: pravinbhingare
3 Replies

6. Solaris

Unexpected mapped volume in Solaris 10

Hi everybody, I'm facing a little trouble with my system. I have a SPARC M4000 server, which connected to a SAN with 2 Brocade 300 Switches and 1 STK 6140. The M4000 has 2 FC HBA cards, one port per card. Each card connect to one switch as follows... ____________M4000____________ ___FC-HBA... (2 Replies)
Discussion started by: nam.nguyen
2 Replies

7. Shell Programming and Scripting

mappin strings of two different file and finding the mapped string and then map other fields.

As i am new to unix so facing some problems in scripting: here is my question: i m having two files. 1st file say a.txt contain 3 column like SPECIALITY|UMP_CODE|SPECIALTY_CODE Addictive Diseases|25ADD|ADD Addictive Diseases/Family Practice|25ADD|ADD/FP Aerospace Medicine|1.041666667|AM... (4 Replies)
Discussion started by: dsh007
4 Replies

8. AIX

how will i know if a lun has been already mapped to a vio client

Hi im logged in to the vio servers now. when i give # lspv | wc -l i get the count as 6246 how will i know if a lun has been already mapped to a vio client or it is left free without mapping to any of the vio client ? (1 Reply)
Discussion started by: newtoaixos
1 Replies

9. Red Hat

Crontab not generating file in mapped drive in windows

Dear Experts, I've schedule scripts with the help of Cronjob, and output should be generated on windows mapped drive, Earlier 2 days its was working fine and now my cronjob is not generating file on windows network drive. Please suggest. Linux details given below. $ tail... (9 Replies)
Discussion started by: Mohammed Fareed
9 Replies

10. Shell Programming and Scripting

mapped reads using samtools flagstat options

Hey guys, Does anyone know how to calculate total number of mapped reads for a certain region of a bam file using samtools flagstat? I know to use flagstat for the whole bam file. but for a specific region of it... is there an option? Tnx ---------- Post updated at 12:27 PM ----------... (1 Reply)
Discussion started by: @man
1 Replies
GIT-REPLACE(1)							    Git Manual							    GIT-REPLACE(1)

NAME
git-replace - Create, list, delete refs to replace objects SYNOPSIS
git replace [-f] <object> <replacement> git replace [-f] --edit <object> git replace [-f] --graft <commit> [<parent>...] git replace -d <object>... git replace [--format=<format>] [-l [<pattern>]] DESCRIPTION
Adds a replace reference in refs/replace/ namespace. The name of the replace reference is the SHA-1 of the object that is replaced. The content of the replace reference is the SHA-1 of the replacement object. The replaced object and the replacement object must be of the same type. This restriction can be bypassed using -f. Unless -f is given, the replace reference must not yet exist. There is no other restriction on the replaced and replacement objects. Merge commits can be replaced by non-merge commits and vice versa. Replacement references will be used by default by all Git commands except those doing reachability traversal (prune, pack transfer and fsck). It is possible to disable use of replacement references for any command using the --no-replace-objects option just after git. For example if commit foo has been replaced by commit bar: $ git --no-replace-objects cat-file commit foo shows information about commit foo, while: $ git cat-file commit foo shows information about commit bar. The GIT_NO_REPLACE_OBJECTS environment variable can be set to achieve the same effect as the --no-replace-objects option. OPTIONS
-f, --force If an existing replace ref for the same object exists, it will be overwritten (instead of failing). -d, --delete Delete existing replace refs for the given objects. --edit <object> Edit an object's content interactively. The existing content for <object> is pretty-printed into a temporary file, an editor is launched on the file, and the result is parsed to create a new object of the same type as <object>. A replacement ref is then created to replace <object> with the newly created object. See git-var(1) for details about how the editor will be chosen. --raw When editing, provide the raw object contents rather than pretty-printed ones. Currently this only affects trees, which will be shown in their binary form. This is harder to work with, but can help when repairing a tree that is so corrupted it cannot be pretty-printed. Note that you may need to configure your editor to cleanly read and write binary data. --graft <commit> [<parent>...] Create a graft commit. A new commit is created with the same content as <commit> except that its parents will be [<parent>...] instead of <commit>'s parents. A replacement ref is then created to replace <commit> with the newly created commit. See contrib/convert-grafts-to-replace-refs.sh for an example script based on this option that can convert grafts to replace refs. -l <pattern>, --list <pattern> List replace refs for objects that match the given pattern (or all if no pattern is given). Typing "git replace" without arguments, also lists all replace refs. --format=<format> When listing, use the specified <format>, which can be one of short, medium and long. When omitted, the format defaults to short. FORMATS
The following format are available: o short: <replaced sha1> o medium: <replaced sha1> -> <replacement sha1> o long: <replaced sha1> (<replaced type>) -> <replacement sha1> (<replacement type>) CREATING REPLACEMENT OBJECTS
git-filter-branch(1), git-hash-object(1) and git-rebase(1), among other git commands, can be used to create replacement objects from existing objects. The --edit option can also be used with git replace to create a replacement object by editing an existing object. If you want to replace many blobs, trees or commits that are part of a string of commits, you may just want to create a replacement string of commits and then only replace the commit at the tip of the target string of commits with the commit at the tip of the replacement string of commits. BUGS
Comparing blobs or trees that have been replaced with those that replace them will not work properly. And using git reset --hard to go back to a replaced commit will move the branch to the replacement commit instead of the replaced commit. There may be other problems when using git rev-list related to pending objects. SEE ALSO
git-hash-object(1) git-filter-branch(1) git-rebase(1) git-tag(1) git-branch(1) git-commit(1) git-var(1) git(1) GIT
Part of the git(1) suite Git 2.17.1 10/05/2018 GIT-REPLACE(1)
All times are GMT -4. The time now is 06:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy