Questions tagged [ls]

A utility in Unix-like systems such as Linux used for listing files and directories.

A utility in Unix and Unix-like operating systems used for listing files and directories. It is analogous to the dir command used in DOS and Windows.

Documentation

1314 questions
27
votes
1 answer

How to hide .pyc files when you enter `ls` in bash

When I perform ls in bash, I always see too many *.pyc files. Is there any way to hide these files?
user2566808
  • 291
  • 3
  • 4
25
votes
5 answers

Using grep and ls -a commands

Using an ls –a and grep, how would you list the name of all of the files in /usr starting with the letter p or the letter r or the letter s using a single grep command? would this be right? ls –a | grep [prs] /usr
Nicole Romain
  • 365
  • 1
  • 3
  • 4
24
votes
3 answers

Which linux system call is used by ls command in linux to display the folder/file name?

I wanted to know which system call is used in linux by the ls command to display the folder's (or file's name)? Especially the files/folders starting with "." (dot) I executed the strace ls -a command to look at the system calls.There is a lot of…
footy
  • 5,803
  • 13
  • 48
  • 96
23
votes
2 answers

How to recursively search for files with certain extensions?

I need to find all the .psd files on my Linux system (dedicated web hosting). I tried something like this: ls -R *.psd, but that's not working. Suggestions?
StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441
23
votes
1 answer

what is ls -F (ls --classify)

Looking at the man pages for plain old ls I see there's a flag for -F -F, --classify append indicator (one of */=>@|) to entries I've used it a few times, but all I see it adds a slash / to folders which is the same as ls -p What does…
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
23
votes
3 answers

tail-like continuous ls (file list)

I am monitoring the new files created in a folder in linux. Every now and then I issue an "ls -ltr" in it. But I wish there was a program/script that would automatically print it, and only the latest entries. I did a short while loop to list it, but…
msb
  • 3,899
  • 3
  • 31
  • 38
23
votes
1 answer

List files matching pattern when too many for bash globbing

I'd like to run the following: ls /path/to/files/pattern* and get /path/to/files/pattern1 /path/to/files/pattern2 /path/to/files/pattern3 However, there are too many files matching the pattern in that directory, and I get bash: /bin/ls: Argument…
DavidR
  • 810
  • 2
  • 8
  • 16
22
votes
3 answers

How can I set default arguments for "ls" in Linux?

Im constantly doing "ls -ahl" whenever I want to list what is in the directory. Is there a way for me to make -ahl the default args passed when I do "ls" or should I just create an alias like "alias lsa=ls -ahl" in bash_profile?
JoshL
  • 1,397
  • 1
  • 12
  • 28
22
votes
3 answers

List of All Folders and Sub-folders

In Linux, I want to find out all Folder/Sub-folder name and redirect to text file I tried ls -alR > list.txt, but it gives all files+folders
Sandeep540
  • 897
  • 3
  • 13
  • 38
21
votes
5 answers

List all files (with full paths) in a directory (and subdirectories), order by access time

I'd like to construct a Linux command to list all files (with their full paths) within a specific directory (and subdirectories) ordered by access time. ls can order by access time, but doesn't give the full path. find gives the full path, but the…
Andrew
  • 897
  • 1
  • 9
  • 19
21
votes
3 answers

issues "using ls -al --full-time" in OSX

--full-time is a handy little option for ls but it doesn't work when used in a batch file. ls -al --full-time when used at the command prompt yields a an expanded date and time: 2012-01-16 18:56:00.000000000 used in a bash script I got this: ls:…
C0ppert0p
  • 634
  • 2
  • 7
  • 23
20
votes
4 answers

How to remove dir background in `ls -color` output

I use default Linux Mint .bashrc, here is full bashrc, the output is like: some dir has green background, How to remove it?
chikadance
  • 3,591
  • 4
  • 41
  • 73
20
votes
4 answers

Implementing the ls -al command in C

As a part of an assignment from one of my classes, I have to write a program in C to duplicate the results of the ls -al command. I have read up on the necessary materials but I am still not getting the right output. Here is my code so far, its only…
ankur3000
  • 203
  • 1
  • 2
  • 5
19
votes
1 answer

How to install and use GNU "ls" on macOS?

I was following this article to update my bash. I really want to update my version of bash so that I can use the --group-directories-first option for the ls command. So far I have accomplished the following from the linked article: I successfully…
im2wddrf
  • 551
  • 2
  • 5
  • 19
19
votes
4 answers

simple loop over files in some directory makefile

I can easily print all the files inside some directory from bash: $ cat go.sh BASEDIR=~/Downloads MYDIR=${BASEDIR}/ddd for f in $(ls ${MYDIR}); do echo $f; done $ ./go.sh m.txt d.txt When I try to do a similar thing from makefile it doesn't work…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87