Help with list filename with total size and divide by 555555
Is the way can run one command line get total size and divide by 555555. Thanks
/export/home/mytmp/test1> ls -ltr testing* -rw-r--r-- 1 ca7prod ftpusers 1179207454 Jan 24 10:18 testing_sftp1_MKT60000_20140108211807_F001.gz -rw-r--r-- 1 ca7prod ftpusers 1179207454 Jan 27 11:00 testing_sftp2_MKT60000_20140108211807_F001.gz -rw-r--r-- 1 ca7prod ftpusers 1179207454 Jan 27 11:12 testing_direc1_F001.gz -rw-r--r-- 1 ca7prod ftpusers 1179207454 Jan 27 11:18 testing_direc2_F001.gz /export/home/mytmp/test1> find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}' 4716829816 I try many way but not work. /export/home/mytmp/test1> find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}' /555555 |bc I like get output: /export/home/mytmp/test1> echo 4716829816/555555 |bc 8490 |
If
Code:
find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}' Why not try this, Code:
MyVar=$(find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}') so, to use it at-will, use MyVar in a function: Code:
GetFilesSizes { Code:
export MyVar=$(find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}) then Code:
echo (( $MyVar/555555 )) Code:
#!/bin/bash |
No...that' second command line. I want run one command line list filename get total sizie and divide by 5555 and output (xxxx)
This command already work just need add divide by 55555 and I can't make it work. find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}' |
Quote:
Code:
$(find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}') / 55555 | bc |
You can also reduce the output of find using -printf and do the calculation with awk:
Code:
find /export/home/mytmp/test1 -name testing\* -printf "%s\n" | awk '{sum+=$1} END{printf "%d\n", sum/55555}' |
somehow still can't make it work.
#!/bin/ksh MyVar=$(find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}') /555555 |bc >> count.txt /export/home/mytmp/test1> ./dd.ksh ./dd.ksh[2]: /555555: not found |
Somehow still can't this code work. Anyone have different syntax? The red part is work. Please help. Thanks
#!/bin/ksh -x MyVar=`find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}'` | echo (( $MyVar/555555 )) /export/home/mytmp/test1> ./dd.ksh ./dd.ksh[2]: syntax error at line 2 : `((' unexpected |
In your command (post #6) the string /555555 is interpreted literally, since the / sign is not inside an arithmetical operator. Moreover you're trying to assign the output of the command to a variable and redirect the output to a file simultaneously. It doesn't make sense.
Take a look at these variants: Code:
echo $(find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}') / 555555 | bc >> count.txt Code:
MyVar=$(echo $(find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}') / 555555 | bc) Code:
MyVar=$(( $(find /export/home/mytmp/test1 -name "testing*" -exec ls -l {} \; | grep -v total | awk '{total += $5};END {print total}') / 555555 )) |
Thanks Mr Colucix. It's worked.
|
All times are GMT -5. The time now is 04:32 PM. |