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 ...
- 08-04-2011 #1
List only directory name
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 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
Code:ls -ld | sed s/\/$//
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
- 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.
Thanks againCode:ls -l | sed "s/\/$//"
Last edited by milind; 08-05-2011 at 07: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
If we hit that bullseye, the rest of the dominoes will fall like a house of cards. Checkmate! (Zapp Brannigan)
My new blog. It's probably not as good as I think it is.
- 08-09-2011 #5Just Joined!
- Join Date
- Aug 2011
- Posts
- 7
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:
See if there is somethink like:Code:alias
You can temporarily get rid of the alias by typingCode:alias ls='ls -hF --color=tty' or alias ls='ls $LS_OPTIONS'
If you want the get rid of the alias permanently, you have to find out which start script contains the alias (~/.bashrc or the likes).Code:unalias ls


Reply With Quote