I have a css file which is this 1.css
/* CSS variables
Generated by 'wal' */
:root {
** --wallpaper: url("/home/x/.local/share/wallpaper/wall.png");**
/* Special */
--background: #10171d;
--foreground: #daccd3;
--cursor: #daccd3;
I want to extract that url link which is in wallpaper url " ". and want to put it in this css file which is this
@-moz-document url(about:home), url(about:newtab), url(about:privatebrowsing) {
.click-target-container *, .top-sites-list * {
color: #fff !important ;
text-shadow: 2px 2px 2px #222 !important ;
}
body::before {
content: "" ;
z-index: -1 ;
position: fixed ;
top: 0 ;
left: 0 ;
**background: #f9a no-repeat url("want to put that link here") center ;**
background-size: cover ;
width: 100vw ;
height: 100vh ;
}
}
I want the link to be in background url of the 2nd css file
I tried some of this commands
awk 'NR==4 { print $2 }' colors.css > 1.txt
cat '1,txt' |sed 's/;.*//' > 2.txt
to extract the link from first file. But I don't know how to import that link to the 2nd css file at the exact place
CodePudding user response:
Put the awk
result in a variable. Then use that variable in sed
to update the CSS file.
url=$(awk '/--wallpaper:/ {print($2)}' colors.css)
sed -E -i '/background:/s#(background: .* )url\([^)]*\)(.*;)#\1'"${url%;}"'\2#' second.css
The %
parameter expansion operator can be used to remove the trailing ;
in $url
.