Results 1 to 5 of 5
Hello, I want to print the name of directories only without slash. here what I am doing 1) when I use command ls -ld it show following drwx------ 4 root ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-04-2011 #1
List only directory name
I want to print the name of directories only without slash. here what I am doing
1) when I use command ls -ld it show following
drwx------ 4 root root 4096 Jul 25 20:10 cpeasyapache/
drwx------ 2 root root 4096 Feb 24 23:21 cprestore/
if you see all the folder which are listed comes with slash in end cpeasyapache/
Is it possible to list all the directories without having /
- 08-04-2011 #2
You could pipe it through sed
ls -ld | sed s/\/$//
- 08-05-2011 #3
Thanks elija for the command it really worked but i gave error
sed: -e expression #1, char 6: unknown option to `s'
After searching on google i used quotes after sed and it worked.
ls -l | sed "s/\/$//"
Last edited by milind; 08-05-2011 at 08:12 AM.
- 08-05-2011 #4
How strange, it worked fine without the quotes on LMDE. Maybe a different version or some kind of funky aliasing going on. Glad you got it sorted out anyway
- 08-09-2011 #5
- Join Date
- Aug 2011
You are using the option -F or -p with ls (probably without you knowing it). Because the plain ls -l does not append the slash at the end of directories.
Maybe there is an alias set for ls. Check by typing:
alias ls='ls -hF --color=tty' or alias ls='ls $LS_OPTIONS'