[英]Replacing Part of Text Using Sed
I have the following text file 我有以下文本文件
Eif2ak1.aSep07
Eif2ak1.aSep07
LOC100042862.aSep07-unspliced
NADH5_C.0.aSep07-unspliced
LOC100042862.aSep07-unspliced
NADH5_C.0.aSep07-unspliced
What I want to do is to remove all the text starting from period (.) to the end. 我要删除的是从句点(。)到结尾的所有文本。 But why this command doesn't do it? 但是为什么这个命令不做呢?
sed 's/\.*//g' myfile.txt
What's the right way to do it? 什么是正确的方法?
You're missing a period there. 你在那里错过了一段时期。 You want: 你要:
s/\..*$//g
you can use awk
or cut
, since dots are your delimters. 您可以使用awk
或cut
,因为点是您的除草剂。
$4 awk -F"." '{print $1}' file
Eif2ak1
Eif2ak1
LOC100042862
NADH5_C
LOC100042862
NADH5_C
$ cut -d"." -f1 file
Eif2ak1
Eif2ak1
LOC100042862
NADH5_C
LOC100042862
NADH5_C
easier than using regular expression. 比使用正则表达式更容易。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.