我有一個 css 檔案,它是 1.css
/* CSS variables
Generated by 'wal' */
:root {
** --wallpaper: url("/home/x/.local/share/wallpaper/wall.png");**
/* Special */
--background: #10171d;
--foreground: #daccd3;
--cursor: #daccd3;
我想提取墻紙網址“”中的那個網址鏈接。并想把它放在這個css檔案中
@-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 ;
}
}
我希望鏈接位于第二個 css 檔案的背景 url
我嘗試了一些這樣的命令
awk 'NR==4 { print $2 }' colors.css > 1.txt
cat '1,txt' |sed 's/;.*//' > 2.txt
從第一個檔案中提取鏈接。但我不知道如何將該鏈接匯入到確切位置的第二個 css 檔案
uj5u.com熱心網友回復:
將awk結果放入變數中。然后使用該變數sed更新 CSS 檔案。
url=$(awk '/--wallpaper:/ {print($2)}' colors.css)
sed -E -i '/background:/s#(background: .* )url\([^)]*\)(.*;)#\1'"${url%;}"'\2#' second.css
引數擴展運算子可用于%洗掉.;$url
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/451503.html
