-1
du -sb /home/user
1001869274      /home/user

How to grep only the numerical value (1001869274 in this case) and store it into a variable, like size=$(du -sb /home/user ...)

call-me-corgi
  • 193
  • 4
  • 10

1 Answers1

1

You can use awk just to print the first column from the output

[ /Downloads - 11:34 AM ]$ du -s /Users/test_user
80839384    /Users/test_user
[ /Downloads - 11:34 AM ]$ du -s /Users/test_user | awk '{print $1}'
80839384
[ /Downloads - 11:34 AM ]$ 

Vaebhav
  • 4,672
  • 1
  • 13
  • 33