I'm using du to get the file size of the result archive in a packager script:> du -smh archive.zip51M    archive.zipI'd like to assign just the 51M part to a variable, to be able to print:Archive size: 51MHow can I do that?
How to extract the file size with du
shell;text processing;disk usage
You can do it like so:$ variable=$(du -smh archive.zip | awk '{print $1}')Detailsawk will parse the output breaking it up into columns. You want just the results from column #1. The $( .. ) code will run a command and return its results.