【发布时间】:2013-01-13 11:57:58
【问题描述】:
如何减少以下冗余?也就是说,有没有办法将两个几乎相同的语句合二为一?
FULFILLMENT="/Users/david/Desktop/pds" # "/Volumes/FulfilmentArray/"
ARCH1="/Users/david/Desktop/etc" # "/Volumes/Arch_01/"
FILE="/tmp/files.txt"
# find all the paths and print them to a file
sudo find $FULFILLMENT -ls | python -c '
import sys
for line in sys.stdin:
r = line.strip("\n").split(None, 10)
fn = r.pop()
print ",".join(r) + ",\"" + fn.replace("\"", "\"\"") + "\""
' > $FILE &&
sudo find $ARCH1 -ls | python -c '
import sys
for line in sys.stdin:
r = line.strip("\n").split(None, 10)
fn = r.pop()
print ",".join(r) + ",\"" + fn.replace("\"", "\"\"") + "\""
' >> $FILE
【问题讨论】:
标签: python linux bash shell unix