I have a file with a string on each line... ie.
我有一个文件,每行都有一个字符串……ie。
test.434
test.4343
test.4343t34
test^tests.344
test^34534/test
I want to find any line containing a "^" and replace entire line with a blank.
我想找到任何包含“^”和替换整个线与一片空白。
I was trying to use sed:
我试着使用sed:
sed -e '/\^/s/*//g' test.file
This does not seem to work, any suggestions?
这似乎行不通,有什么建议吗?
2 个解决方案
#1
4
sed -e 's/^.*\^.*$//' test.file
For example:
例如:
$ cat test.file test.434 test.4343 test.4343t34 test^tests.344 test^34534/test $ sed -e 's/^.*\^.*$//' test.file test.434 test.4343 test.4343t34 $
To delete the offending lines entirely, use
要完全删除有问题的行,请使用
$ sed -e '/\^/d' test.file test.434 test.4343 test.4343t34
#2
0
other ways
其他的方式
awk
awk
awk '!/\^/' file
bash
bash
while read -r line
do
case "$line" in
*"^"* ) continue;;
*) echo "$line"
esac
done <"file"
and probably the fastest
可能最快的
grep -v "\^" file
#1
4
sed -e 's/^.*\^.*$//' test.file
For example:
例如:
$ cat test.file test.434 test.4343 test.4343t34 test^tests.344 test^34534/test $ sed -e 's/^.*\^.*$//' test.file test.434 test.4343 test.4343t34 $
To delete the offending lines entirely, use
要完全删除有问题的行,请使用
$ sed -e '/\^/d' test.file test.434 test.4343 test.4343t34
#2
0
other ways
其他的方式
awk
awk
awk '!/\^/' file
bash
bash
while read -r line
do
case "$line" in
*"^"* ) continue;;
*) echo "$line"
esac
done <"file"
and probably the fastest
可能最快的
grep -v "\^" file