Avatar of Swaminathan K
Swaminathan K
Flag for India asked on

Unix Command -- Challenging question

Hi Team,

I need an help on the unix command, I need to write an single command which will display the number of files in the current directory.
I tried the below command , but not getting the desired output.

ls-al | grep "^d|^ " | wc -l

Any help is really appreciated.
System ProgrammingUnix OSLinuxShell Scripting

Avatar of undefined
Last Comment
Swaminathan K

8/22/2022 - Mon
serialband

What are you trying to do with the grep  That should return nothing or blank because there's no way you can have the start (^) of line in 2 places.

Are you trying to just display files, and not links nor directories?
ls -la |grep -v "^d" |grep -v "^l"|wc
Swaminathan K

ASKER
Hi I mean both . any help is reallly appreciated
SOLUTION
Seth Simmons

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
omarfarid

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Gerwin Jansen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
serialband

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Swaminathan K

ASKER
awesome. Thanks a lot.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck