[wellylug] a bit of data bashing

Christian Arndt car at itmania.de
Tue Mar 24 18:09:44 NZDT 2015


Hi,

On 03/24/2015 02:15 PM, Olly Betts wrote:
> Although this works, be aware that it will open and close "filname.txt"
> for every iteration of the loop - if you're looping a lot, that can add
> up.  Better to just redirect output for the whole for loop instead:
> 
>     $ for i in {1..10}; do echo file00000$i.whatever ;done > filname.txt

Very good point!

Furthermore backticks `` are deprecated and should be replaced by using
$() instead. So probably

    for file in $(seq -f 'file%06g.whatever' 1 19)
    do
        echo $file
    done > filename.txt

is the best mixture of all solutions. :)

Cheers!

-- 

Best regards,
http://www.itmania.de/gpg.pub e-mail
http://www.itmania.de/ssh.pub    ssh



More information about the wellylug mailing list