Use the -e
option. Look it up in man sed
So in your case you could do:
cat tmp.txt | grep '[0-9]*.[0-9]' \
| sed -e 's/[\t ]//g' \
-e "s/ | //g" \
-e "s/kB\/s\((.*)\)//g" \
-e "s/<\/td>//g" > traffic.txt
You can also write it in another way as:
grep ".* | " tmp.txt | sed 's/\([0-9.]\+\).*/\1/g'
The \+ matches one or more instances, but it does not work on non-GNU versions of sed. (Mac has BSD, for example)
With help from @tripleee's comment below, this is the most refined version I could get which will work on non-GNU versions of sed as well:
sed -n 's/\([0-9]*.[0-9]*\).*/\1/p' tmp.txt
As a side note, you could also simply pipe the outputs through each sed instead of saving each output, which is what I see people generally do for ad-hoc tasks:
cat tmp.txt | grep '[0-9]*.[0-9]' \
| sed -e 's/[\t ]//g' \
| sed "s/ | //g" \
| sed "s/kB\/s\((.*)\)//g" \
| sed "s/<\/td>//g" > traffic.txt
The -e option is more efficient, but the piping option is more convenient I guess.
|
|
|
|