파일을 필터링하여 모든 경로를 나열합니다.

파일을 필터링하여 모든 경로를 나열합니다.

텍스트 파일을 필터링하여 모든 콘텐츠를 제거하고 그 안에 있는 경로만 유지하려면 어떻게 해야 합니까? 예를 들어:

dslkjcblasdjncklasdnlc /asdds/ads/adss/sdf.jpg asljdascuashn sdkm
/sdf/dsf/dsf/dfs/sdfs.txt ,nbaskhdnasm.ddslkjcblasdjncklasdnlc
/asdds/ads/adss/sdf.jpg asljdascuashn sdkm /sdf/dsf/dsf/dfs/sdfs.txt
,nbaskhdnasm.ddslkjcblasdjncklasdnlc /asdds/ads/adss/sdf.jpg
 asljdascuashn sdkm /34/34/dsf/dfs/sdfs.txt
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /asdds/ads/adss/sdf.jpg
 asljdascuashn sdkm /sdf/dsf/dsf/dfs/sdfs.txt
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /sd/df/fg/fgsdf.jpg asljdascuashn
 sdkm /sdf/dsf/34/dfs/sdfs.txt ,nbaskhdnasm.ddslkjcblasdjncklasdnlc
 /asdds/ads/adss/sdf.jpg asljdascuashn sdkm /sdf/dsf/dsf/dfs/sdfs.txt
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /qw2/sd23/adss/sdf.jpg
 asljdascuashn sdkm /34/34/dsf/dfs/sdfs.png
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /asdds/ads/adss/sdf.jpg
 asljdascuashn sdkm /sdf/dsf/dsf/dfs/sdfs.txt
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /wre/ads/adss/sdf.nii
 asljdascuashn sdkm /sdf/dsf34/dsf/dfs/sdfs.pmb
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /asdds/ads/adss/sdf.jpg
 asljdascuashn sdkm /sdf/dsf/dsf/dfs/sdfs.txt
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /34/ads/34/sdf.jpg asljdascuashn
 sdkm /34/dsf/dsf/34/sdfs.dbt ,nbaskhdnasm.ddslkjcblasdjncklasdnlc
 /asdds/ads/adss/sdf.jpg asljdascuashn sdkm /sdf/dsf/dsf/dfs/sdfs.txt
 ,nbaskhdnasm.ddslkjcblasdjncklasdnlc /34/34/34/sdf.zip asljdascuashn
 sdkm /sd34f/dsf/dsf/34/sdfs.tar.gz ,nbaskhdnasm.d

모든 것을 제거하고 경로만 유지하여 다음을 얻으려면 어떻게 해야 합니까?

/asdds/ads/adss/sdf.jpg 
/sdf/dsf/dsf/dfs/sdfs.txt 
/asdds/ads/adss/sdf.jpg 
/sdf/dsf/dsf/dfs/sdfs.txt 
/asdds/ads/adss/sdf.jpg 
/34/34/dsf/dfs/sdfs.txt 
/ads/adss/sdf.jpg 
/sdf/dsf/dsf/dfs/sdfs.txt 
/sd/df/fg/fgsdf.jpg 
/sdf/dsf/34/dfs/sdfs.txt 
/asdds/ads/adss/sdf.jpg 
/sdf/dsf/dsf/dfs/sdfs.txt 
/qw2/sd23/adss/sdf.jpg 
/34/34/dsf/dfs/sdfs.png
/asdds/ads/adss/sdf.jpg 
/sdf/dsf/dsf/dfs/sdfs.txt 
/wre/ads/adss/sdf.nii 
/sdf/dsf34/dsf/dfs/sdfs.pmb 
/asdds/ads/adss/sdf.jpg 
/sdf/dsf/dsf/dfs/sdfs.txt 
/34/ads/34/sdf.jpg
/34/dsf/dsf/34/sdfs.dbt
/asdds/ads/adss/sdf.jpg 
/sdf/dsf/dsf/dfs/sdfs.txt 
/34/34/34/sdf.zip 
/sd34f/dsf/dsf/34/sdfs.tar.gz 

답변1

GNU grep의 옵션을 사용 -o하고 파일 경로가 공백으로 구분되어 있다고 가정합니다.

grep -o '/[^ ]*' < input

관련 정보