wget -O test https://unsplash.com/ko/s/%EC%82%AC%EC%A7%84/image
src 속성을 추출하려면 다음과 같은 grep 명령어를 사용하면 됩니다:
grep -o 'src="[^"]*"' test | grep -o '"[^"]*"' | sed 's/"//g'
이 명령어는 'test' 파일에서 'src' 속성과 관련된 모든 부분을 찾습니다. 첫 번째 grep 명령어는 'src="([^"]*)"' 패턴을 찾아서 해당 부분을 출력하고, 두 번째 grep 명령어는 첫 번째 grep 결과에서 따옴표(")로 둘러싸인 부분을 찾아서 해당 부분을 출력합니다. 마지막으로 'sed' 명령어가 따옴표를 제거하면 최종적으로 'src' 속성값만이 출력됩니다.
[root@localhost ~]# grep -o 'src="[^"]*"' test | grep -o '"[^"]*"' | sed 's/"//g'
명령어 사용 결과
/_next/static/chunks/polyfills-a40ef1678bae11e696dba45124eadd70.js
/_next/static/chunks/webpack-92cbb7ec579f20ec511d.js
/_next/static/chunks/framework-2191d16384373197bc0a.js
/_next/static/chunks/main-49d174673b24cccd6a5c.js
/_next/static/chunks/pages/_app-5fa553dd2ecb58134d23.js
/_next/static/chunks/a79515f9-240cebbd9596ecd566db.js
/_next/static/chunks/587-5c52c94b9ce2d7f05908.js
/_next/static/chunks/443-fa43d594a4a8144af95d.js
/_next/static/chunks/199-2719079eca505fd25eca.js
/_next/static/chunks/706-48e79fe7fbee5a6dee12.js
/_next/static/chunks/26-686a94ec3877f3e99844.js
/_next/static/chunks/311-5885e26aee65de3db8d3.js
/_next/static/chunks/pages/service/%5BserviceAlias%5D/category/%5BcategoryAlias%5D-00ae75069db9399119b8.js
/_next/static/rO1Am9zl2WovRPB-WIMXT/_buildManifest.js
/_next/static/rO1Am9zl2WovRPB-WIMXT/_ssgManifest.js
https://ssl.pstatic.net/static/common/myarea/myInfo.gif