FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu User

 
 
LinkBack Thread Tools
 
Old 11-28-2009, 07:02 PM
John Abbott
 
Default ls command refuses to give just folder names per command line switch

On Sat, 2009-11-28 at 11:41 -0800, Ray Parrish wrote:


Hello,

I have been trying to figure out why ls will not return folder names
only as per the man page's insistence that it will with the -d switch.
Here is output from Terminal

ray@RaysComputer:~/links$ ls --directory
.
ray@RaysComputer:~/links$

No sub folders returned from the ls command. Yet when I run the
following, you can see the first few lines are all folders that clearly
exist in that Directory.

ray@RaysComputer:~/links$ ls -a --classify --group-directories-first
./
../
Desktop/
GSD/
Images/
scripts/
Video/
481445.png
AddURLtoGoogleSitemapScript.html
AddURLtoGoogleSitemapScript.html~
AddURLtoSitemap.sh.zip

What I'm trying to get ultimately is a recursive list of all files of a
certain type in all sub folders of the current folder, including the
current folder. But when I add the --recursive command, and include a
*.html on the end, all I get is a list of the .html files in the current
folder, and none from any of the sub folders. Like so -

ray@RaysComputer:~/links$ ls -x -1 --recursive *.html
AddURLtoGoogleSitemapScript.html
Biology.html
bookmarks.html
BootingintoSafeMode.html
buttonbar.html
Change Skin.html
CharitableOrganizations.html
Combatting Spam.html
Comparison of Windows and Ubuntu Linux.html
Computer.html
Computer Tips and Tutorials.html
Email Information.html
EnvironmentalIssues.html
error404.html
EtherApeNetworkSecurityTool.html
FomentingResponsibleLeadership.html
google34436ce73104f9d5.html
GUIWebSiteMonitor.html
GUIWrapperforWebChangeMonitorScript.html
HardDiskRequirementsXPServicePack3.html
Hard Drives.html
HowToInstallSoftwareinUbuntu.html
How To Install Ubuntu.html
How to speed up and organize tab switching in Firefox.html
index.html
InformationAboutWindowsXPServicePack3.html
InsuringResponsibleLeadership.html
Internet.html
Internet Radio Stations.html
Internet Speed Test.html
Is The Eiffel Tower Taller than the Space Needle.html
Learning Linux References.html
Linux distributions and documents.html
LinuxMonitorWebPageforChangeScript.html
MissingTitlebarsinUbuntu.html
NoMorePaidLobbyists.html
Offline Browsing Tools.html
OnlineMagazines.html
PasswordLoadingScript.html
PayingofftheNationalDeficit.html
PossibleProblemsXPServicePack3.html
PostingRules.html
Programming.html
ReleasingHungModem.html
ScienceandTechnology.html
Security Measures.html
Skinning Web Sites.html
StimulusInvestigation.html
Submit Link.html
Survey Sites.html
Template.html
ThankYou.html
The Future of Technology.html
TimerStopWatchScriptforLinux.html
Troubleshooting and fixing Windows.html
Troubleshooting HiJackThis Log Files.html
Troubleshootings Tools for Windows.html
Video.html
Visual Basic Tips.html
Web Browsers.html
Web Editors.html
Web Hosting.html
Web Publishing.html
Web Site Monitor.html
WhatisHardDiskFragmentation.html
Whatisrecursion.html
WhereAreProgramFilesinUbuntu.html
Where to go to get help.html
Why Dual Boot.html
Windows XP SP3 installation.html
ray@RaysComputer:~/links$

Note that none of that output came from any of the sub folders, so
--recursive is not staying the course. I can get a recursive listing,
but it includes all file types, and the sub folder names in it's output.

Is there any way to get just the sub folder names? Is there any way to
get a recursive listing of all of only one file type, with their
relative path to the current folder included on each line?

Thanks for any help you can be, Ray Parrish

--
The Future of Technology.
http://www.rayslinks.com/The%20Future%20of%20Technology.html
Ray's Links, a variety of links to usefull things, and articles by Ray.
http://www.rayslinks.com
Writings of "The" Schizophrenic, what it's like to be a schizo, and other
things, including my poetry.
http://www.writingsoftheschizophrenic.com





Sounds like a job for find and grep


--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-28-2009, 07:13 PM
Nils Kassube
 
Default ls command refuses to give just folder names per command line switch

Ray Parrish wrote:
> I have been trying to figure out why ls will not return folder names
> only as per the man page's insistence that it will with the -d
> switch. Here is output from Terminal
>
> ray@RaysComputer:~/links$ ls --directory
> .
> ray@RaysComputer:~/links$
>
> No sub folders returned from the ls command.

I think that's OK. What you asked ls to do is list the current directory
but only the directory, not the contents. And the current folder is ".".
If you want to list the directories within the current directory you
could use

ls -d */

instead.

> What I'm trying to get ultimately is a recursive list of all files of
> a certain type in all sub folders of the current folder, including
> the current folder. But when I add the --recursive command, and
> include a *.html on the end, all I get is a list of the .html files
> in the current folder, and none from any of the sub folders.


Then use the find command. What you want is something like this:

find -type f -name *.html

> ray@RaysComputer:~/links$ ls -x -1 --recursive *.html

Other than the Windows shell, bash expands this command and replaces the
"*.html" expression with a list of the .html files in your current
directory, i.e. something like

ls -x -1 --recursive file1.html file2.html

and those are no directories, so the "--recursive" parameter isn't
useful here.


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-28-2009, 08:09 PM
Florian Diesch
 
Default ls command refuses to give just folder names per command line switch

Nils Kassube <kassube@gmx.net> writes:

> Ray Parrish wrote:
>> I have been trying to figure out why ls will not return folder names
>> only as per the man page's insistence that it will with the -d
>> switch. Here is output from Terminal
>>
>> ray@RaysComputer:~/links$ ls --directory
>> .
>> ray@RaysComputer:~/links$
>>
>> No sub folders returned from the ls command.
>
> I think that's OK. What you asked ls to do is list the current directory
> but only the directory, not the contents. And the current folder is ".".
> If you want to list the directories within the current directory you
> could use
>
> ls -d */
>
> instead.
>
>> What I'm trying to get ultimately is a recursive list of all files of
>> a certain type in all sub folders of the current folder, including
>> the current folder. But when I add the --recursive command, and
>> include a *.html on the end, all I get is a list of the .html files
>> in the current folder, and none from any of the sub folders.
>
> Then use the find command. What you want is something like this:
>
> find -type f -name *.html

At least in 9.10 Bash supports **/*.html to match recursively all .html
files - at least until the maximum command line length isn't reached.



Florian
--
<http://www.florian-diesch.de/software/shell-scripts/>

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-28-2009, 09:17 PM
Nils Kassube
 
Default ls command refuses to give just folder names per command line switch

Florian Diesch wrote:
> At least in 9.10 Bash supports **/*.html to match recursively all
> .html files - at least until the maximum command line length isn't
> reached.

That doesn't really look recursive to me. Here it only matches files in
any of the subdirectories of the current directory but not in the
current directory or sub-subdirectories. Am I missing something?


Nils

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-28-2009, 09:39 PM
Florian Diesch
 
Default ls command refuses to give just folder names per command line switch

Nils Kassube <kassube@gmx.net> writes:

> Florian Diesch wrote:
>> At least in 9.10 Bash supports **/*.html to match recursively all
>> .html files - at least until the maximum command line length isn't
>> reached.
>
> That doesn't really look recursive to me. Here it only matches files in
> any of the subdirectories of the current directory but not in the
> current directory or sub-subdirectories. Am I missing something?

Oops yes, sorry, used the wromng prompt. It's still working only with
zsh, not bash.


Florian
--
<http://www.florian-diesch.de/software/pdfrecycle/>

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 
Old 11-28-2009, 11:52 PM
James Michael Fultz
 
Default ls command refuses to give just folder names per command line switch

* Ray Parrish <crp@cmc.net> [2009-11-28 11:41 -0800]:
[...]
> Is there any way to get just the sub folder names?

$ find . -type d -print

Or only subdirectories containing certain files.

$ find . -type f -name '*.html' -printf '%h
' | uniq

> Is there any way to get a recursive listing of all of only one file
> type, with their relative path to the current folder included on each
> line?

$ find . -type f -name '*.html' -print

--
ubuntu-users mailing list
ubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
 

Thread Tools




All times are GMT. The time now is 02:05 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org