1

So i am trying to write a script to search through a directory and find the number files with the same type. I tried this:

find $directory -type f | file -b $SAVEFILES | cut -c1-40 | sort -n | uniq -c | sort -nr |

but the number of how many times the the same type is there is before the type and look like this:

    168 ASCII TEXT

How do I access value of the number and store it and afterwards move it after the text like this:

ASCII TEXT: 168
Cyrus
  • 84,225
  • 14
  • 89
  • 153
Adam
  • 99
  • 2
  • 8

1 Answers1

2

Append with GNU sed:

| sed 's/^ *\([0-9]\+\) \(.*\)/\2: \1/'

or

| sed -r 's/^ *([0-9]+) (.*)/\2: \1/'
Cyrus
  • 84,225
  • 14
  • 89
  • 153