I have many files in a folder:
$ ls -hlS | head
total 75M
-rw-r--r-- 1 ubuntu ubuntu 511 Aug 3 16:27 NW_009517088.1.lst
-rw-r--r-- 1 ubuntu ubuntu 478 Aug 3 16:27 NW_009539008.1.lst
-rw-r--r-- 1 ubuntu ubuntu 471 Aug 3 16:27 NW_009386266.1.lst
-rw-r--r-- 1 ubuntu ubuntu 471 Aug 3 16:27 NW_009411177.1.lst
-rw-r--r-- 1 ubuntu ubuntu 451 Aug 3 16:27 NW_009514912.1.lst
The content of each *.lst
file looks as following:
$ cat NW_009514912.1.lst
rna-NisyCt036+
cds-YP_358756.1-
rna-NisyCt037+
cds-YP_358757.1+
cds-YP_358758.1+
cds-YP_358758.1+
id-NisyCp117-1+
id-NisyCp117-2+
id-LOC104209938-1-
rna-XM_009770987.1-
rna-XM_009780247.1+
rna-XM_009783083.1+
rna-XM_009784022.1-
rna-TRNAN-GUU+
How is it possible to delete from each *.lst
file, line which do not start with rna-XM_
?
find ... | xargs sed -i ...
. The find may need to be prevented from descending subdirectories, and the invariant part of the filename needs to be defined (like, is the .1.lst fixed). Can you read up those man pages, and show where you get stuck? – Paul_Pedant Aug 03 '20 at 08:02find query/ -name "*.lst" | xargs sed -i '/^rna-XM_/d'
doesn't work. What did I miss? – user977828 Aug 03 '20 at 10:23'/^rna-XM_/!d'
– Rakesh Sharma Aug 03 '20 at 11:10query/
? – ctrl-alt-delor Aug 03 '20 at 11:55