Over writing output to a text file

Posted by Naveen Gamage on Super User See other posts from Super User or by Naveen Gamage
Published on 2013-11-12T09:24:34Z Indexed on 2013/11/12 10:00 UTC
Read the original article Hit count: 232

Filed under:
|
|
|

I'm trying to write wget command's output to a text file, but it always appends to the text file.

#!/bin/sh
download()
{
    local url=$1
    echo -n "    "
    wget --progress=dot $url 2>&1 | grep --line-buffered "%" | \
        sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
    echo " DONE"
}

file="$1"
echo -n "Downloading $file:"
download "$file" > file.log

I tried using using > won't work, where am I doing wrong?

© Super User or respective owner

Related posts about linux

Related posts about bash