[英]identifying leading line space - shell script
我有如下示例文件。 有引導線空間。 有沒有一種方法可以檢測到它們並使用Shell腳本打印包含行空間的確切行號?
test space at back
test space at front
TAB at end
TAB at front
grep可以使用[:blank:]來查找空格,並使用^(regex)來查找行首
grep -n
將打印行號
嘗試grep -n '^[[:blank:]]' filename
這對我有用! 如果grep -n'^'config.js / dev / null>&2; 然后回顯“ $ 0:上面標識的前導空格;正在中止”>&2退出1 fi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.