ls -l | grep



JasKinasis

Well-Known Member
Credits
1,193
Hello,
why when i use ls -l with grep it doesnt show any results but with ls it give me the results

View attachment 5132
The reason is because ls and ls -l format their output differently.

Your pattern is matching the start of the line. And because ls only lists the file/directory names - your pattern will work with ls.

However, when you use ls -l, the listing format starts with the permissions, user/group, file-size, time-stamp and the file-name is at the end.
So in this case - rather than matching the start of the line, your pattern needs to match the end of the line instead.
So remove the ^ at the start of the pattern and add $ at the end:
e.g.
ls -l | egrep [Ff]raise$
That should work with ls -l
 


Members online

No members online now.

Latest posts

Top