How do you echo the folder name your currently in (using SHELL)?
Hi,
Im trying to find out how I can show what folder im currently in shell. I had a little go with "ls" but could only get it to show all folders, not just the one im in. Any help with this would be great :) |
You can use pwd command.
|
Ah thanks alan_ri, your a legend :)
|
Wait, no not quite what I wanted,
I was hoping for just the folder not the full path. eg, directory: /home/users/TECHNO/ Output: You are in the folder TECHNO |
Type in the terminal:
Code:
export PS1="\W $ " |
No thats not what I wanted, I want to be able to have the folder name so I can use it in a echo script.
But don't worry I got a friend to help out. This is what he/she gave to me (and it does what I wanted): Code:
echo $PWD | sed -e "s#[^/]*/##g" |
Sweet. :D
Well,you've showed us how it's done. |
This might be more readable to some ...
Code:
basename $(pwd) |
Oh nice, thats much cleaner, thanks.
|
All times are GMT -5. The time now is 10:51 AM. |