need help with displaying only names using ls -l

Hi I am kind of stuck

I need help with printing only the names of the folder in the format

LAST NAME, F

so last name and the first character of first name

using ls -l command in the /home directory

currently they are in the format firstname.lastname

please advice

Try:

ls -l | awk '/^d/{split($NF,N,".");print N[2]", "substr(N[1],1,1)}'

or

ls -l | sed -n '/^d/{s/.* \(.\).*\.\(.*\)/\2, \1/p}'
1 Like

thanks for your reply.

is there a way of doing it with out using awk ?

Hi,
I posted a sed alternative as well would that work? What are you looking for?

1 Like

Thanks thats brilliant it all worked perfectly.