LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-02-2014, 03:44 AM   #1
ksy2011s
LQ Newbie
 
Registered: Aug 2014
Posts: 1

Rep: Reputation: Disabled
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.
 
Old 08-02-2014, 11:43 AM   #2
jwiggins
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Rep: Reputation: Disabled
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.
 
1 members found this post helpful.
Old 08-02-2014, 12:04 PM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command/Script required to send an email alert in case command will not respond rajaniyer123 Linux - General 1 05-19-2012 02:12 PM
Executing shell command from JSP file with command line arg from URL orcusomega Programming 2 01-13-2012 04:38 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 12:21 PM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 03:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 07:30 PM


All times are GMT -5. The time now is 12:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration