我有這個變數:
a='/08/OPT/imaginary/N/08_i_N.out'
我想使用“/”作為欄位分隔符。
然后,我想提取第一個模式。
我努力了:
awk -F/ '{print $1}' "$a"
但我得到:
awk: cannot open /08/OPT/imaginary/N/08_i_N.out (No such file or directory)
我不想要該檔案,只需要處理該檔案的路徑。
uj5u.com熱心網友回復:
與任何其他命令相同的方式,其中任何一個(或其他替代方法,例如在“here-documents”中或作為 awk 變數傳遞或...):
printf '%s\n' "$a" | command
command <<<"$a"
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/417462.html
標籤:
