Since apt is a front end for dpkg, I wonder if using dpkg itself might work better.
I have started the remastering process working off the 5.3.1 DVD release. I know the packages I want to remove and have compiled them into a text file.
I thought I would just make a simple bash script to remove them, but it always aborts after a few minutes with no real info as to why.
Here is what I have:
#!/bin/bash
apt-get --force-yes --purge remove packagename
If I run each command it works, but not in the script
I have also tried:
cat filewithnames.txt | xargs apt-get --force-yes --purge remove
This ends with the following: "Do you want to continue? Y/n Abort"
Same issue.
For the record, there are approx. 2500 packages that I want to remove. Is there a hard limit?
Since apt is a front end for dpkg, I wonder if using dpkg itself might work better.
If I script like so:
#!/bin/bash
dpkg -r packname
and so on
It just throws bad interpeter errors
When you run the script
#!/bin/bash
apt-get --force-yes --purge remove packagename
What exactly is the message that you get? I don't remember whether apt-get requires confirmation in this syntax. If it does you may have to redirect standard input to the script itself for each invocation and provide the yes/no response there.
cmd << text
The contents of the shell script up to a line identical to text become the standard input for cmd.

Genuine Cisco SFP-10G-SR 0-2415-03 10 Gigabit Transceiver
$5.40
Dell Intel X710-DA2 5N7Y5 Dual-Port 10GbE SFP+ PCIe 3.0 x8 Network Adapter
$27.50
Cisco Acacia DP04QSDD-E25-840 400G QSFP-DD Coherent DCO Transceiver Module
$699.99
NEW Sealed Cisco SFP-10G-LR 10GBASE-LR SFP+ 1310nm 10km *US Shipping*
$24.00
HPE 10/25GbE 2Port SFP28 Intel E810 OCP3 Network Adapter NIC 2 Port 10G 25G 25GE
$609.00
SFP TO RJ45 TRANSCEIVER SFP MODULE COPPER SFP OPTICAL PORT TO RJ45 ETHERNET PORT
$7.99
Intel X520-DA2 10Gb 10Gbe 10 Gigabit Network Adapter NIC Dual Port E10G42BTDA
$28.94
HP 560SFP+ 10GB 2-port PCIe NIC Ethernet ADAPTER 669279-001 w/ (2) 10GB SFP+
$16.99
CISCO 10GBASE-SR SFP "Lot of 4” SFP-10G-SR
$47.99
HPE P10109-B21 MCX512F-ACAT 10/25GbE Dual-Port SFP28 NIC P10107-001 P12608-001
$100.00