Tip jar

If you like CaB and wish to support it, you can use PayPal or KoFi. Thank you, and I hope you continue to enjoy the site - Neil.

Buy Me a Coffee at ko-fi.com

Support CaB

Recent

Welcome to Cook'd and Bomb'd. Please login or sign up.

April 27, 2024, 02:13:37 PM

Login with username, password and session length

Deleting items from a list

Started by pigamus, December 16, 2022, 08:48:51 PM

Previous topic - Next topic

pigamus

I've got a list of things stored as a text file. I want to delete some items, but it's quite a long list, and deleting them one by one is going to be tedious.

I'm wondering if there's some other way? That will let me select individual items like you'd select email for deletion?

The Guppy

Triple-click selects a whole paragraph, if that helps.

pigamus

Yeah, if they were all together in groups... less good if you want to delete items 4, 9 and 21, for example

It's one of those things that should be easy but I don't think actually is

Or else somebody's going to say "Why don't you just....?" and make me look fucking stupid

The Guppy

On a Mac I would hold Option, then triple click each item I want to delete, so I only have those items selected. Not sure what you'd hold on Windows. Maybe Alt?

edit: I'm assuming it's a list
formatted
like this

and not a list, of things, all on one line, which would be way harder.

pigamus

yes
it is like
this

Yes it's a Mac - which program are you talking about?

The Guppy

Tested it in Notes, just double checked in TextEdit. So I'd assume it works in all text editors and word processors.

But it doesn't work right here in this edit box.

Command is the universal "select a few things but not everything in between" modifier on a Mac.


edit: doesn't work in Pages, a more newfangled thing than TextEdit. Jobs is spinning in his grave.

pigamus

That's only going to select one item at a time though isn't it?

pigamus

Oh wait a minute! Couldn't get it to work in TextEdit but in Notes it works! Well that's bloody useful, thank you!

The Guppy


Sebastian Cobb

if you're on a mac another option is to open a terminal to the same location as the file and do
grep -v -e 'pattern1' -e 'pattern2' -e 'and so on' input_file.txt > output_file.txt

touchingcloth

That's overkill if you're using a Mac. You can just say

QuoteHey, Siri, delete ^.*<pattern>.*$

Sebastian Cobb

I have no idea how to say '^' aloud.

touchingcloth


olliebean

Quote from: The Guppy on December 16, 2022, 09:27:02 PMOn a Mac I would hold Option, then triple click each item I want to delete, so I only have those items selected. Not sure what you'd hold on Windows. Maybe Alt?

Ctrl.