What does cd $(ls -d *) command do?
Dear All,
I'm very new in Linux OS, recently, I was try to understand one shell script, there I found one command "cd $(ls -d *)" can you please explain the command? Thanks in advance. |
answer
well, the $( ... ) means to execute this command first; ls -d * shows a listing of every file and, if it's a directory, only show the directory name and not what is inside the directory (that's what the -d does), so what the command does in the script is it finds the first directory and enters it I'm guessing to do commands inside. If that helps any.
|
Stop using that script, it is poorly written
That little bit of 'code' only works if a single directory in the current dir. Post the script so we can fix it, or point out alternatives |
All times are GMT -5. The time now is 03:22 PM. |