Parameter substitution in loops
I'm trying the following loop to process a bunch of files and create a new filename for the output file, but it's not working. Also, I want to make the new value for TT to be five digits, with a leading zero.
Basically, I need to extract every 10 thousandth line from a bunch of input files. In each output file, I want to include a 5 digit line number in each output file's filename (so I know where it came from). My current code just hangs (on further inspection, it created a whole bunch of strangely named files which I now must get rid of). Code:
for ((TT=10000; TT<=100000; TT+=10000)) |
Actually, I have it almost working (so there!, all you experts). I still need a five digit number in the first iteration.
Code:
for ((TT=9999; TT<30000; TT+=10000)) |
On third thought, nevermind. It seems I need the 10,000th line and every 10 thousand after that. So I don't even have to pad the zeros.
|
I would probably use awk with NR%10000, then you need neither loop (as awk will handle it) and then just process the files as required.
|
All times are GMT -5. The time now is 04:35 PM. |