0

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
1

1 Answer 1

2

You can use the tr command:

echo abc | tr abc bcd

This outputs:

bcd
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.