Which command can extract just number from a line or text file?
Hi people,
I'm using du command: du folder_name and that gives me the result, for example: 8 folder_name I wonder- how can I get just that 8 (that number) without the name of folder next to it? (I want to do that because I want to assign that value to a variable in a script.) Or if I write the result of command in a text file: du folder_name > some_file, how can I get that number (in this case 8)from that file? |
Code:
du folder_name | awk '{print $1}' You can also use -s for summary, and -h for human readable format (e.g., 1K 234M 2G) Code:
du -sh folder_name | awk '{print $1}' |
Thank you very much! It works.
Edit: I know that switches, thanks... |
All times are GMT -5. The time now is 06:59 AM. |