Jim Witte wrote:
>
> Hello,
>
> I'm updating a script that manages the .htpasswd file on *N*X boxes.
> The user records are stored on successive lines, in the form
> $username:$password. What I want to do is find a particular $username,
> then delete the entire line.
Perhaps this module has
> "A" == A Rivera <[EMAIL PROTECTED]> writes:
A> Wouldn't
A> cat filename | grep -v "text to ignore"
A> be simplest?
I'd consider
grep -v "text to ignore" filename
simpler, and it avoids the useless use of cat.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 5
Wouldn't
cat filename | grep -v "text to ignore"
be simplest?
Agustin
- Original Message -
From: "Jim Witte" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, November 29, 2001 8:09 AM
Subject: Elegant way t
> -Original Message-
> From: Bkwyrm [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 29, 2001 12:22 PM
> To: [EMAIL PROTECTED]
> Subject: [[EMAIL PROTECTED]: RE: Elegant way to
> find/remove
> line from text file]
>
>
> Tested these in order to lear
> perl -ni -e 'next unless /foo/' myfile.txt
Actually, finally got this to work this way to remove all lines but those containing
foo:
perl -ni -e 'next unless /foo/; print;' myfile.txt
and this way for all those not containing foo:
perl -ni -e 'next if /foo/; print;' myfile.txt
--
Na
Tested these in order to learn how they work, and the first one simply deleted the
entire contents my test file which was peppered with foo on multiple (but not all)
lines
- Forwarded message from Bob Showalter <[EMAIL PROTECTED]> -
Second, the canonical one-liner to delete lines f
> -Original Message-
> From: Jim Witte [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 29, 2001 11:09 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Elegant way to find/remove line from text file
>
>
> Hello,
>
> I'm updating a scr
Hello,
I'm updating a script that manages the .htpasswd file on *N*X boxes.
The user records are stored on successive lines, in the form
$username:$password. What I want to do is find a particular $username,
then delete the entire line.
The current code reads the entire file into an array,