All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Output filtering
It has been a long time and I am not really into advanced filtering output of Linux commands with grep, awk and other tools.
What I want to do is filter out used and free RAM of free -m.
My command so far:
free -m | grep - | awk -F : '{print $2}'
Output example:
14 1009
14 is used and 1009 is free.
Now I need to split this output into two commands so one gives out the used amount and the other the free amount.
Been trying stuff with cut and so on but the problem is that the example output is $2 in whole so the whole thing gets cut out and the output is empty. Not that it would have been easier if free -m would have put $2 in for used and $3 for free...
So how do change my filter command into two different to filter out the amount of used and free memory?
Comments
Do you even test your commands?
I get the same output from it as from mine.
@NekoShiinachan
So basically I could do cram=$(free -m | grep - | awk -F : '{print $2}') and then do freeram=$(echo $cram | cut -d" " -f1) and usedram=$(echo $cram | cut -d" " -f2) ?
Isn't that what you wanted?
Exactly.
Edit: or you could do
Edit: or you coudl get more memory with:
No, that was the output of my command.
Should have described it better.
@perennate troll somewhere else
The output of your command had a lot more spaces than the output of my command, which is why you wouldn't be able to pass it as $2 $3 as arguments to another program. Anyway, hopefully socials solved your problem.
@black
Yes, that was the problem because the output that was generated by filtering is $2 of "free -m" while "-/+ buffers/cache:" is $1 of the filtered "free -m".
And the because the output "14 1009" was the whole $2 the cutting failed because you always cut away the whole thing because the whole output is $2.