ls behavior


 
Thread Tools Search this Thread
Top Forums Programming ls behavior
# 1  
Old 03-22-2002
ls behavior

I put this here because it is a 'behavior' type question..
I seem to remember doing ls .* and getting all the .-files, like
.profile
.login

etc.

But ls .* doesn't do that, it lsts the contents of every .*-type subdirectory.

Is it supposed to?
I should think that a -R should be given to dive into subdirs?
All I have access to are Solaris, BSD and Linux, what is with the others?

AtleSmilie Smilie
# 2  
Old 03-22-2002
If I understand you question correctly

Your ls .* is finding the two directories . & .. (your current directory & the one a step back up the hierarchy)

use ls -d .* to supress printing the contents of these.
# 3  
Old 03-22-2002
Quote:
Originally posted by Kevin Pryke
If I understand you question correctly

Your ls .* is finding the two directories . & .. (your current directory & the one a step back up the hierarchy)
Not as bad as that, it is not going up, but down.
It is printing all the stuff in .xauth, .netscape, etc.
Quote:

use ls -d .* to supress printing the contents of these.
Thanks, that did it.
Alias set up instantly Smilie
# 4  
Old 03-22-2002
When you type "ls .*", what is happening is that your shell is expanding the "*" to ".sh_history .netscape/ .profile .blah .less/" and everything else starting with a ".".

The -d flag tells ls not to go into the directories, like it would if you did it the way above.

I have a very usefull alias:

alias l.='ls -ld .[a-zA-Z0-9]*'

so when I type "l.", it gives me a long listing of all the dot-files and directories without going into them, and without listing "." and "..".
# 5  
Old 03-22-2002
Quote:
Originally posted by LivinFree

alias l.='ls -ld .[a-zA-Z0-9]*'
Thanks, LivinFree, that's exactly what I was looking for, even better than just stupidly aliasing ls itself!

L miss those l, lc and ll and whatever they wre called. You reminded me to make them!
Smilie

If you want to have some more fun, I'm setting up a 'hackers corner' (hacker in the true sense of the word, of course, not as in 'intruder') at

http://atle.linux-site.net

it is a little cryptic, so it actually goes like this
/cgi-bin/signon.cgi - signon
/cgi-bin/manager.cgi - manage

For the kind of people mention belov Unix only Smilie

That is: Smilie and Smilie

Atle
# 6  
Old 03-22-2002
I never knew I would miss ll and the others until I used HP-UX for the first time... Now, the first thing I do on a new system is set up my ls alias' !

Here's some other helpful ones:

alias lr='ls -ltr'
lsd () { ls -l $@|grep "^d" ; }
alias emode='set -o emacs'
alias vmode='set -o vi'

Boy, do I love Unix!
# 7  
Old 03-22-2002
& amen 2 that Smilie

Not to start a shell war, but what is your favourite shell?
I've sort of rediscovered csh these days, it's really a shame that it seems to be losing out.

if ($< == "q") echo "yes"

is sort of 'natural' to a C programmer ...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Weird behavior of Vi

Hi there, I am a bit puzzled by a weird behavior of Vi. I very simply would like to add increased numbers in some files. Since I have many thousands entries per file and many files, I would like to macro it in vi. To do this, I enter the first number ("0001") on the first line and then yank... (4 Replies)
Discussion started by: hypsis
4 Replies

2. AIX

LUN Behavior

Aix 6.1, working with a nim master and nim_altmaster both LPARS have access to the same data LUN, /nimdisk I do realize the risks of having 2 servers access the same LUN, however it serves the purpose of being able to restore mksysb's to/from our DR site if necessary, at least in theory ;) ... (3 Replies)
Discussion started by: mshilling
3 Replies

3. HP-UX

Unusual Behavior?

Our comp-operator has come across a peculiar ‘feature'. We have this directory where we save all the reports that were generated for a particular department for only one calendar year. Currently there are 45,869 files. When the operator tried to backup that drive it started to print a flie-listing... (3 Replies)
Discussion started by: vslewis
3 Replies

4. Programming

Strange behavior in C++

I have the following program: int main(int argc, char** argv){ unsigned long int mean=0; for(int i=1;i<10;i++){ mean+=poisson(12); cout<<mean<<endl; } cout<<"Sum of poisson: "<< mean; return 0; } when I run it, I get the... (4 Replies)
Discussion started by: santiagorf
4 Replies

5. Shell Programming and Scripting

Echo behavior

Echo is removing extra blank spaces. See the command. export INSTALLDIR=”First Second /Two Space” echo $INSTALLDIR out put: First Second /Two Space Here only on blnak space is present while with command Echo “$INSTALLDIR” Out put: ”First Second /Two Space” It's correct output... (2 Replies)
Discussion started by: Saurabh78
2 Replies

6. Shell Programming and Scripting

sed behavior on hp-ux

the sed command: sed 's/^*//' file does not work on HP-UX :-( but it works fine on Linux, content of file: <tab><tab>hello output should be: hello Any ideas?? Thank you Andy (8 Replies)
Discussion started by: andy2000
8 Replies

7. HP-UX

ltoa Behavior

I am working with the following code: #include <stdlib.h> #include <string> #include <iostream> using std::cout; using std::endl; using std::flush; int main() { long lng1 = 123; long lng2 = 4567; cout<<ltoa(lng1)<<ltoa(lng2)<<endl<<flush; return 0; } Instead of receiving... (2 Replies)
Discussion started by: charitonca
2 Replies

8. Programming

Behavior of pthreads

Hi All, I ve written a small program to get started off with pthreads. I somehow feel the program doesnt meet the purpose. Please find the code and the output below. Please find my question at the bottom. #include <pthread.h> #include <stdio.h> #include <stdlib.h> void *PrintThread1(void... (4 Replies)
Discussion started by: nhrraj
4 Replies

9. UNIX for Dummies Questions & Answers

Telnet behavior

Hi there, I've an stupid question. If I make a telnet to a server from my computer and then execute a command that starts an application (on the server), when I disconnect, the application stops running, which is pretty obvious. Is it possible to add a flag at the end of the command so when I cut... (4 Replies)
Discussion started by: piltrafa
4 Replies
Login or Register to Ask a Question