Skip to main content
added 2 characters in body
Source Link
slm
  • 380k
  • 127
  • 793
  • 897

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 parenthesis
  • s/ [[: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 $1 and $2 variables. In this case we're matching everything up to but not including the space + parenthesis in $1 and everything after the open parenthesis that's not a space \S+ in the 2nd variable, $2.

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 parenthesis
  • s/ [[:alpha:]]\+\/s.*$// - deletes everything starting from the space + 'MB/s' to the end .*$.

Another way using Perl:

$ 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 $1 and $2 variables. In this case we're matching everything up to but not including the space + parenthesis in $1 and everything after the open parenthesis that's not a space \S+ in the 2nd variable, $2.

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 parenthesis
  • s/ [[:alpha:]]\+\/s.*$// - deletes everything starting from the space + 'MB/s' to the end .*$.

Another way using perl:

$ 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 $1 and $2 variables. In this case we're matching everything up to but not including the space + parenthesis in $1 and everything after the open parenthesis that's not a space \S+ in the 2nd variable, $2.
added 499 characters in body
Source Link
slm
  • 380k
  • 127
  • 793
  • 897

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:How it works:

  • s/(//; - deletes the first parenthesis
  • s/ [[:alpha:]]\+\/s.*$// - deletes everything starting from the space + 'MB/s' to the end .*$.

Another way using Perl:

$ 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 $1 and $2 variables. In this case we're matching everything up to but not including the space + parenthesis in $1 and everything after the open parenthesis that's not a space \S+ in the 2nd variable, $2.

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 parenthesis
  • s/ [[:alpha:]]\+\/s.*$// - deletes everything starting from the space + 'MB/s' to the end .*$.

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 parenthesis
  • s/ [[:alpha:]]\+\/s.*$// - deletes everything starting from the space + 'MB/s' to the end .*$.

Another way using Perl:

$ 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 $1 and $2 variables. In this case we're matching everything up to but not including the space + parenthesis in $1 and everything after the open parenthesis that's not a space \S+ in the 2nd variable, $2.
Source Link
slm
  • 380k
  • 127
  • 793
  • 897

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 parenthesis
  • s/ [[:alpha:]]\+\/s.*$// - deletes everything starting from the space + 'MB/s' to the end .*$.