Jump to content

Need Command Line Help

Go to solution Solved by fjdhdhcyfhf,

NUMBER=$(find /etc -type f | wc -l)

echo "The number of files and directories in /etc on $(date) is $(NUMBER)"

Hello,

Just a heads up I;m using CentOS. So I need to find the number of files and directories in another directory and I need that to be outputted in this format "The number of files and directories in /etc on Thu Oct 16 17:18:16 PDT 2014 is 6162". So far I used the command find /etc -type f | wc -l | awk '{ print strftime(), $0; fflush() }' >output.txt but it just gives me the date and number of files and directories. I need to get it worded correctly. Please help.

Link to comment
https://linustechtips.com/topic/732131-need-command-line-help/
Share on other sites

Link to post
Share on other sites

1 minute ago, thegingertator said:

YOU ARE A GOD.

I made a typo there shouldnt be brackets in $(NUMBER) it should be

 

echo "The number of files and directories in /etc on $(date) is $NUMBER"

 

             ☼

ψ ︿_____︿_ψ_   

Link to comment
https://linustechtips.com/topic/732131-need-command-line-help/#findComment-9301293
Share on other sites

Link to post
Share on other sites

3 minutes ago, SCHISCHKA said:

I made a typo there shouldnt be brackets in $(NUMBER) it should be

 

echo "The number of files and directories in /etc on $(date) is $NUMBER"

 

I also have to take a log file and find the number of failed login attempts. and output it in the form of " There were 67 failed login attempts between 6:20 and 6:24 on Oct 19th." Any ideas?

Link to comment
https://linustechtips.com/topic/732131-need-command-line-help/#findComment-9301301
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×