I’m trying to use the following awk script to count every 1000 records from file named file.txt and enclose those records between brackets
content of file.txt
12345
23456
43567
awk '{ printf $0 " " } NR%1000 == 0 { print "" }' file.txt | sed 's/.*/(&)/'
output
(12345 23456 43567)
I need to assotciate this output with mysql bulk delete statement such as the following
Delete from ReportingDetail where ReportingDetailID IN (12345,23456,43567);
- I’m unable to add “Delete from ReportingDetail where
ReportingDetailID IN” to the birnining of every line. - I’m unable to add “,” between records.
Your help is highly appreciated!
You can do this only with sed:
E.g.:
Edit – for your update (i.e. when you have numbers on different lines), just prepend what you already had:
E.g.:
You can also do that without awk like this:
Note the echo I used is just for testing, i.e. this is what it produces: