开发者

shell script filter question

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开发者_JAVA百科 make sure every file name are on different lines?

thanks in advance


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.


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

shopt -s extglob
ls !(*.txt)


ls -al | grep -v "file-pattern-you-want-to-filter-out"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜