LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices



Reply
 
Search this Thread
Old 11-09-2007, 09:47 AM   #1
sysslack_linux
LQ Newbie
 
Registered: Oct 2007
Location: Sweden
Distribution: I favor Slackware, CentOS and Debian
Posts: 25

Rep: Reputation: Disabled
How do you list dot files only in bash?


Is it possible to list only files starting with (.) a dot
I have googled a lot and have found the answer!
I almost succedded
echo .*
.DCOPserver_tux_:0 .DCOPserver_tux__0 .ICEauthority .Xauthority .adobe .bash_history .bash_profile .bash_profile~ .bashrc .bashrc~ .config .firefox .fontconfig .fullcircle .java .kde .kderc .ktorrent.lock

But how do you do when you want them listed like this ?
.DCOPserver_tux_:0
.DCOPserver_tux__0
.ICEauthority
.Xauthority
.adobe
.bash_history
.bash_profile
.bashrc
.config
.firefox
.fontconfig
.fullcircle
.java
.kde
.kderc
.ktorrent.lock

Last edited by sysslack_linux; 11-09-2007 at 09:50 AM.
 
Old 11-09-2007, 10:16 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Code:
find ./ -maxdepth 1 -type f -iname ".*"
edit: or
Code:
echo .* | tr " " "\n"

Last edited by pwc101; 11-09-2007 at 10:17 AM.
 
Old 11-09-2007, 10:47 AM   #3
teek
Member
 
Registered: Jun 2004
Location: The Netherlands; Dordrecht
Distribution: Arch (at the moment)
Posts: 110

Rep: Reputation: 16
type:

ls .

Then hit tab a couple of times
 
Old 11-09-2007, 11:02 AM   #4
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by teek View Post
type:

ls .

Then hit tab a couple of times
Unfortunately, that also lists directories (my first thought was "What's wrong with ls .*?").
 
Old 11-09-2007, 11:08 AM   #5
teek
Member
 
Registered: Jun 2004
Location: The Netherlands; Dordrecht
Distribution: Arch (at the moment)
Posts: 110

Rep: Reputation: 16
ah... hehe, ok, I already thought this was too simple
Sorry
 
Old 11-09-2007, 12:46 PM   #6
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
This nearly works on my machine with bash 3.2.0, excpet that it prints out the '.' and '..' dirs:

Code:
echo .* | tr " " "\n"
But this works quite well:
Code:
echo .* | tr " " "\n" |tail +3
 
Old 11-09-2007, 01:05 PM   #7
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by gnashley
But this works quite well:
Code:
echo .* | tr " " "\n" |tail +3
That's a nice fix

I timed the find command and the echo command:
Code:
500 pwc101@jessie ~$ bash --version
GNU bash, version 3.00.15(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
501 pwc101@jessie ~$ time echo .* | tr " " "\n" | tail +3
real    0m0.003s
user    0m0.001s
sys     0m0.002s
502 pwc101@jessie ~$ time find ./ -maxdepth 1 -type f -iname ".*"
real    0m0.003s
user    0m0.002s
sys     0m0.001s
Not much in it!
 
Old 11-10-2007, 02:19 PM   #8
sysslack_linux
LQ Newbie
 
Registered: Oct 2007
Location: Sweden
Distribution: I favor Slackware, CentOS and Debian
Posts: 25

Original Poster
Rep: Reputation: Disabled
Thank you very much for your suggestions!
I have tried them all and they worked on my machine!
 
  


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
Need bash script to list files, drop extension and dump to file talwar_ Programming 10 06-03-2011 10:18 AM
Bash scripting problem: Can't get a list of all files, including hidden ones oxi Programming 24 03-12-2007 07:19 AM
what's that dot command in bash scripts? stabu Linux - Software 4 12-07-2006 12:33 PM
A list of files I own in bash? subnet_rx Linux - Software 4 07-10-2006 01:01 PM
RSYNC and dot files Buto Linux - General 1 09-22-2005 03:39 PM


All times are GMT -5. The time now is 10:58 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration