views:

82

answers:

3

I am trying to store the resulting list from "ls -la" into a variable then filter out some files name, after that print out only the filtered file names (along with the date and stuff like how ls -la does it" again, but when I do that everything is in one line, is there a way to make sure every file name are on different lines?

thanks in advance

+3  A: 

Use a pipe instead of storing it in a variable.

ls -la | filter

Where filter is whatever you're using to filter.

That's about as good an answer as I can give unless you can provide some more details on exactly what you're trying to do.

Brian Campbell
thanks a lot for the answer
Shellscriptbeginner
+1  A: 
ls -al | grep -v "file-pattern-you-want-to-filter-out"
chinmaya
As long as the pattern can't occur in the other junk that `ls -l` provides...
dmckee
+2  A: 

if you want to filter file names, eg , don't list all txt files

shopt -s extglob
ls !(*.txt)
ghostdog74
thankyou so much for the fast reply
Shellscriptbeginner