简体   繁体   中英

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

You can use the tr command:

echo abc | tr abc bcd

This outputs:

bcd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM