[英]UNIX how to remove a line which has only comma and space
UNIX如何刪除僅包含逗號和空格的行以下示例
dfasdfs,fasfsafsaf,dfasfasfs,sfd
dsfsafsa,fsafafsad
safsafas,fsafsaf,
,,,
asfdasf,asdfddsfas,
我需要刪除[,,,]行。 請注意,開始,結束或之間可能會出現空格
sed -i '/^[ ,]*$/d' file --- > Didn't work
你能幫忙嗎? 謝謝
只需使用grep:
grep '[^ ,]' file
使用sed可以是:
sed -n '/[^ ,]/p' file
請注意,這也會刪除空白行,請讓我們知道是否存在問題。
使用grep:
grep -v '^[ ,]*$' file
嘗試這個
awk ' { if ( $1 !~ /^[ ,]/ ) { print } ; } ' test.txt
sed -e '/[[:space:],]/d' file.txt
使用選項-i保留這些更改:
sed -i '/[[:space:],]/d' file.txt
這對我sed -i '/^ [ ,]*$/d' file
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.