Link to home
Start Free TrialLog in
Avatar of Durga Ojha
Durga OjhaFlag for India

asked on

in Linux, need one SHELL Script for How many files currently open

in Linux, need one SHELL Script for How many files currently open
Avatar of Durga Ojha
Durga Ojha
Flag of India image

ASKER

any help please
Avatar of Alex [***Alex140181***]
you'll need the LSOF command for this I guess

https://en.wikipedia.org/wiki/Lsof
ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes its LSOF command .. but I need to create a script file .. by running it will write the output in a log file with the currently opened files in Linux
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Durga Charan Ojha - why did you use 'Request Attention'? You can just ask about that number 38025 here by posting a comment.

The output of this simple script I suggested is showing date/time + text + number of files. If you just want the number then do this:

 echo $(lsof | grep REG | wc -l) >> output.txt
Hi Gerwin Jansen, EE MVE
Do you mean 38025  is the number of file opened in linux ?
Let say I have firefox, chrome and one libre office file opened .. is there any command to check this from ssh
so that output will show only for the opened applications
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried only lsof - the output keeps on running .. i just closed the terminal
as said I need only output like as i know in the machine I have just opened chrome, firefox, editor
so it should show output .
>> I tried only lsof
Of course it does, you should just wait patiently (it will stop after some time) or apply a filter like "-c firefox"

Just try for firefox first:

lsof -c firefox | grep REG | wc -l

should give you just the number.

lsof -c firefox | grep REG

this should show you the files
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial