Sorting GREP output
Hi
Have these two grep commands for file in ~/webhits/*; do echo "$file: "$(grep $MONTH "$file" | grep -c $YEAR); done for file in ~/webhits/*; do echo "$file: "$(grep $MONTH "$file" | grep $YEAR|cut -d" " -f 1,7|sort -u |wc -l); done that produce outputs that look like: /home/luke/webhits/bluray.hits: 8 /home/luke/webhits/books.hits: 7 /home/luke/webhits/cds.hits: 6 /home/luke/webhits/computing.hits: 7 /home/luke/webhits/dvds.hits: 7 /home/luke/webhits/gadgets.hits: 3 /home/luke/webhits/games.hits: 8 /home/luke/webhits/garden.hits: 5 /home/luke/webhits/home.hits: 3 /home/luke/webhits/index.hits: 24 /home/luke/webhits/jewellery.hits: 5 /home/luke/webhits/kitchen.hits: 4 /home/luke/webhits/posters.hits: 4 /home/luke/webhits/shoes.hits: 4 /home/luke/webhits/watches.hits: 4 Just wondering how to sort them by numeric order Thanks in advance |
Run the output through sort -n.
Edit: you probably need to sort by the number field only, so use "sort -n -k2" instead. |
All times are GMT -5. The time now is 08:09 AM. |