0

Hi I am a python bigginer, I have a scenario where I need to search and select a particular value from linux command "df -h".

dumpe2fs 1.42.13.x5 (23-Mar-2017)
Inode count:              786432000
[root@copper02 ~]#

In this above output I need to store the inode count number in to a variable to use it for further calculation.
Can anyone explain how to use python regular expressions to do the above task?

Edited by Reverend Jim: Moved to programming forum

2
Contributors
1
Reply
10
Views
4 Months
Discussion Span
Last Post by Reverend Jim
0

You don't need a regex for that. Just take any line starting with Inode count, split on blanks, then take the last element. Or, if you pipe the output from df to grep you can filter out only the Inode count lines. Pipe the output from that to your script and read the values from stdin.

Edited by Reverend Jim

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.