Bash to search a csv for numbers and copy to a new file?

Commissario
Joined
16 Oct 2002
Posts
342,976
Location
In the radio shack
Hi folks,

After a couple of hours of messing around with this, I'm struggling.

I have two files, one is a text file consisting of a a bunch of numbers in this format

123556
213452
529521
134525

The second is a csv, the rows are quite long but it's a standard csv, nothing special. That csv starts with a six digit number.

I need to search the csv for any rows that start with a number from the first file and then move that entire row out to a new file. Moving it might be tricky, it may be easier just to copy the row into a new file.

The column of numbers is about 1500 numbers long and the csv is about 45,000 so it's quite a big job.

With how well *nix works with text files, I thought this would be quite straightforward but I'm struggling.

Can anyone help please?

Thanks.
 
Part of the couple of hours I spent on this was trying to get chatgpt to produce working code! It either gave me zero output to the file whatsoever or it sat there for twenty minutes chuntering away and then gave me zero output.
 
Back
Top Bottom