storing 'du' result in a variable

1.6k views Asked by At

I am using Putty with bash-4.2. Therein, I am outputting file size with:

du -m myfile.csv

which returns:

1.25 myfile.csv

How do i store this line in a variable so I can later parse out the filesize?

Thanks in advance

1

There are 1 answers

1
Mulan On BEST ANSWER

Like so

FOO="$(du -m myfile.csv)"
echo "$FOO"

Output

1.25 myfile.csv