파일에 다음 데이터가 있습니다.
one,1,/home/steven/Transformation/users.txt
two,2,/home/steven/Transformation/users.txt
그리고 나는 다음과 같은 ouptut를 원합니다.
one,1,users.txt
two,2,users.txt
awk를 사용하여 이것을 처리하는 방법
방법 1
awk -F "," 'OFS=","{print $1,$2,substr($NF,29)}' filename
방법 2 :
sed "s/\/.*\///g" filename
방법 3 :
#!/usr/bin/python
import re
k=re.compile(r'/.*/')
p=open('p.txt','r')
for i in p:
print re.sub(k,"",i).strip()
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다