Thursday, January 5, 2012

print urls in a css file

Print the URLs in a css file:

sed -rn 's/^.*url\((.+\.[a-z]+)\).*$/\1/p' file.css

I had a css file that referenced a some images in a directory that contained lots of images and wanted to move just the images referenced in the css file to a new directory, so ended doing something along the lines of:

for p in $(sed -rn 's/^.*url\((.+\.[a-z]+)\).*$/\1/p' file.css); do cp ~/old_path/css/$p new_path/$p; done

No comments:

Post a Comment