<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Linux Forum &mdash; Удаление строк по маске легко, а если масок много ?]]></title>
	<link rel="self" href="https://linuxforum.ru/extern.php?action=feed&amp;tid=26240&amp;type=atom" />
	<updated>2013-01-24T11:48:31Z</updated>
	<generator>PunBB</generator>
	<id>https://linuxforum.ru/viewtopic.php?id=26240</id>
		<entry>
			<title type="html"><![CDATA[Re: Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322623#p322623" />
			<content type="html"><![CDATA[<p>Спасибо, учту. Хотя в этот раз я по ошибке не тот файл подсунул.</p><p>P.S. Использую su&nbsp; <img src="https://linuxforum.ru/img/smilies/bs.gif" alt="bs" /></p>]]></content>
			<author>
				<name><![CDATA[vovanvster]]></name>
				<uri>https://linuxforum.ru/profile.php?id=3626</uri>
			</author>
			<updated>2013-01-24T11:48:31Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322623#p322623</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322617#p322617" />
			<content type="html"><![CDATA[<p>Чтобы не было проблем со спец. символами, используйте fgrep или grep -F.</p><p>ЗЫ. И не работайте от root <img src="https://linuxforum.ru/img/smilies/bx.gif" alt="bx" /></p>]]></content>
			<author>
				<name><![CDATA[-=Serj=-]]></name>
				<uri>https://linuxforum.ru/profile.php?id=16175</uri>
			</author>
			<updated>2013-01-24T11:26:57Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322617#p322617</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322611#p322611" />
			<content type="html"><![CDATA[<p>Второй вариант не подходит если значений несколько десятков. А от grep я таких чудес не ожидал.<br />Пойду внимательно читать man grep.</p><p>Да, с использованием grep всё получилось. Спасибо Вам огромное.</p>]]></content>
			<author>
				<name><![CDATA[vovanvster]]></name>
				<uri>https://linuxforum.ru/profile.php?id=3626</uri>
			</author>
			<updated>2013-01-24T10:52:55Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322611#p322611</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322609#p322609" />
			<content type="html"><![CDATA[<p><div class="termtitle" style="font-family: sans-serif; position:relative; height:auto; width:auto; background:#3A4061; color:#FFFFFF; padding: 1px;"><b> Консоль:</b></div>
<div class="termcont" style="font-family: Terminus; position:relative; height:auto; width:auto; overflow-x:scroll; white-space: nowrap ; overflow-y:auto;background:#000000; color:#4EF44E; line-height:1.2; padding: 3px; font-size: 1rem; max-height: 60vh"><br />lupo@gentoo-laptop /tmp $ sed -i &#039;/[123|789]/d&#039; file_1.txt<br />lupo@gentoo-laptop /tmp $ cat file_1.txt<br />456dfyjh<br />456fjthk<br />456jzdfjj<br /></div></p>]]></content>
			<author>
				<name><![CDATA[Lupo Alberto]]></name>
				<uri>https://linuxforum.ru/profile.php?id=9018</uri>
			</author>
			<updated>2013-01-24T10:41:55Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322609#p322609</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322608#p322608" />
			<content type="html"><![CDATA[<p><div class="termtitle" style="font-family: sans-serif; position:relative; height:auto; width:auto; background:#3A4061; color:#FFFFFF; padding: 1px;"><b> Консоль:</b></div>
<div class="termcont" style="font-family: Terminus; position:relative; height:auto; width:auto; overflow-x:scroll; white-space: nowrap ; overflow-y:auto;background:#000000; color:#4EF44E; line-height:1.2; padding: 3px; font-size: 1rem; max-height: 60vh"><br />lupo@gentoo-laptop /tmp $ cat file_1.txt <br />123djhjkd<br />123drhg<br />123sshjkds<br />456dfyjh<br />456fjthk<br />456jzdfjj<br />789dhgj<br />789fgkjj<br />lupo@gentoo-laptop /tmp $ cat file_2.txt <br />123<br />789<br />lupo@gentoo-laptop /tmp $ grep -v -f file_2.txt file_1.txt <br />456dfyjh<br />456fjthk<br />456jzdfjj<br /></div></p>]]></content>
			<author>
				<name><![CDATA[Lupo Alberto]]></name>
				<uri>https://linuxforum.ru/profile.php?id=9018</uri>
			</author>
			<updated>2013-01-24T10:39:33Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322608#p322608</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322607#p322607" />
			<content type="html"><![CDATA[<p>К сожалению этого не достаточно. Из первого файла надо удалить все строки которые содержат в себе как фрагменты строки из второго файла.</p><div class="codebox"><pre><code>#cat file_1.txt
123djhjkd
123drhg
123sshjkds
456dfyjh
456fjthk
456jzdfjj
789dhgj
789fgkjj

#cat file_2.txt
123
789

#sed -i /&quot;123&quot;/d file_1.txt

#sed -i /&quot;789&quot;/d file_1.txt

#cat file_1.txt
456dfyjh
456fjthk
456jzdfjj</code></pre></div><p>В данном примере надо удалить строки которые содержат &quot;123&quot; и &quot;789&quot;.</p>]]></content>
			<author>
				<name><![CDATA[vovanvster]]></name>
				<uri>https://linuxforum.ru/profile.php?id=3626</uri>
			</author>
			<updated>2013-01-24T10:26:29Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322607#p322607</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322598#p322598" />
			<content type="html"><![CDATA[<p>Если нужно удалить именно строку, достаточно возможностей <em>grep</em>:<br /><div class="termtitle" style="font-family: sans-serif; position:relative; height:auto; width:auto; background:#3A4061; color:#FFFFFF; padding: 1px;"><b> Консоль:</b></div>
<div class="termcont" style="font-family: Terminus; position:relative; height:auto; width:auto; overflow-x:scroll; white-space: nowrap ; overflow-y:auto;background:#000000; color:#4EF44E; line-height:1.2; padding: 3px; font-size: 1rem; max-height: 60vh"><br />lupo@gentoo-laptop /tmp % cat template.txt<br />123<br />456<br />789<br />lupo@gentoo-laptop /tmp % cat test.txt<br />123<br />234<br />345<br />678<br />456<br />789<br />lupo@gentoo-laptop /tmp % grep -v -f template.txt test.txt<br />234<br />345<br />678<br /></div></p>]]></content>
			<author>
				<name><![CDATA[Lupo Alberto]]></name>
				<uri>https://linuxforum.ru/profile.php?id=9018</uri>
			</author>
			<updated>2013-01-24T09:42:42Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322598#p322598</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Удаление строк по маске легко, а если масок много ?]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=322596#p322596" />
			<content type="html"><![CDATA[<p>При помощи sed очень просто удалять строки содержащие определённые слова. (Решено)</p><p>sed -i /&quot;string&quot;/d file.txt</p><p>А если значений &quot;string&quot; много ? Можно ли автоматизировать чтобы не пришлось снова и снова вводить одну и ту же команду с разными значениями ? Какой нибудь простой скрипт, для считывания по очереди строк из одного файла и передачи их для sed в качестве масок.</p><p>Понимаю что для этой задачи надо написать что-то на питоне но для начала меня устроит и самое простое решение.<br />Заранее благодарен.</p>]]></content>
			<author>
				<name><![CDATA[vovanvster]]></name>
				<uri>https://linuxforum.ru/profile.php?id=3626</uri>
			</author>
			<updated>2013-01-24T09:34:58Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=322596#p322596</id>
		</entry>
</feed>
