Here's an alternative using sed:
$ wget -O /dev/null ftp://someftpsite:[email protected]/testdump300 2>&1 | \ sed 's/(//;s/ [[:alpha:]]\+\/s.*$//' >> wget300.log How it works:
s/(//;- deletes the first parenthesiss/ [[:alpha:]]\+\/s.*$//- deletes everything starting from the space + 'MB/s' to the end.*$.
Another way using Perlperl:
$ wget -O /dev/null ftp://someftpsite:[email protected]/testdump300 2>&1 | \ perl -lne 'print "$1 $2" if /^(.*)\s\((\S+)/' >> wget300.og How it works:
- anything wrapped in parenthesis in Perl will be saved, hence the
$1and$2variables. In this case we're matching everything up to but not including the space + parenthesis in$1and everything after the open parenthesis that's not a space\S+in the 2nd variable,$2.