LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 02: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, 10: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, 11:04 AM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
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



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 01:12 PM
Executing shell command from JSP file with command line arg from URL orcusomega Programming 2 01-13-2012 03:38 PM
Bash Command Line Editor, while typing run another command before executing current? gumaheru Linux - General 5 04-13-2010 11:21 AM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:52 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
Open Source Consulting | Domain Registration