Lionultra107
Lionultra107

Reputation: 47

Write an equivalent GNU/Linux command

How can I write an equivalent GNU/Linux command which gives the same output as the script? The input to the command should be the same as the variable var1 in the following script.

#!/bin/python
my_char = { 'a':'b', 'b':'c', 'c':'d'}
var1 = "abc"
var2 = ""
for ch in var1:
   if ch in my_char:
     var2+=my_char[ch]
   else:
     var2+=ch
 print var2

Upvotes: 0

Views: 50

Answers (1)

blhsing
blhsing

Reputation: 106891

You can use the tr command:

echo abc | tr abc bcd

This outputs:

bcd

Upvotes: 2

Related Questions