tr
从标准输入中替换,缩减,删除字符,并将结果写到标准输出 -d 删除字符 -s 保留连续字符的第一个字符,删除其他字符 -c 使用第一个字符串的补集,取反
✘ ~/Desktop cat code.py
class A:
def __enter__(self):
a = 1
def __exit__(self):
b = 2
with A() as obj:
print(obj)
~/Desktop tr 'class' 'Module' < code.py
Modll A:
def __enter__(leof):
d = 1
def __exit__(leof):
b = 2
with A() dl obj:
print(obj)
大小写转换
~/Desktop tr '[a-z]' '[A-Z]' < code.py
CLASS A:
DEF __ENTER__(SELF):
A = 1
DEF __EXIT__(SELF):
B = 2
WITH A() AS OBJ:
PRINT(OBJ)
删除字符
✘ ~/Desktop tr -d 'A' < code.py
class :
def __enter__(self):
a = 1
def __exit__(self):
b = 2
with () as obj:
print(obj)
删除文件中的换行,制表符
~/Desktop tr -d '\n\t' < code.py
class A:def __enter__(self):a = 1def __exit__(self):b = 2with A() as obj:print(obj)%