The command to list the contents of a folder/directory in Unix and Unix-like systems.

learn more… | top users | synonyms

0
votes
2answers
21 views

Exclude a directory from `ls -R` command in FreeBSD

I want to list all of my files in a directory in FreeBSD 9.2, but I don't want to include a specific directory. I checked both -I and --ignore parameters for ls, but I only ignores superuser mode and ...
0
votes
1answer
18 views

rename top 10 latest file according to their names

I have some .xls files in a defined directory (say in /A/B). I want to rename top 10 latest files and append "-bkp" in their names. I tried, not working ls -lt *.xls | head -1 | awk '{print "mv " ...
0
votes
0answers
25 views

How to have error output from `ls` if target directory is empty

I'm currently learning how to use the Linux shell, getting to grips with the basic commands like cd, ls and pwd. My file structure is like so: user |-- documents |-- file1.pdf |-- file2.txt ...
64
votes
6answers
50k views

How to have Linux ls command show second in time stamp

Something annoying about ls -l command is it shows only hour and minute for a file(like 08:30). How can I see the second portion(like 08:30:44)? man 1 ls and search for 'second' does not give any ...
1
vote
3answers
39 views

Sort by `ls -l` Dates Without Using `ls`

I have a text file with a bunch of ls -l output, such as: -rw-r--r-- 1 root root 7554952082 Dec 15 22:11 /var/spool/stuff/Investigation/messages.tgz -rw-r--r-- 1 root root 4315 Mar 3 2015 ...
2
votes
1answer
1k views

Why doesn't ls show the group name?

When I use ls -l, it does NOT show the group names in the listings. Only the user names. aj@host:/media/storage$ ll total 724 drwxrwxrwx 10 root 4096 Sep 17 18:23 . drwxr-xr-x 3 root ...
0
votes
2answers
14 views

display number of files in current moment like what tail -f do

I have a folder which files are copied to it like /home/my/. I want to run a command which shows number of files inside it in real time like what tail -f do with file contents. I know I should run ls ...
3
votes
5answers
6k views

Run an ls without getting the full path

I want a simple list of files in a directory that is not my current directory. I run ls /other/directory/*.txt and get: /other/directory/file1.txt /other/directory/file2.txt I want: file1.txt ...
-1
votes
1answer
64 views

File does NOT exist but ls shows “No such file or directory” error

File system ext4 // which ls -> /bin/ls // Bash -> 3.2.57(2)-release // whoami -> admin If I run ls then I firstly get a list of files with error "No such file or directory" and ...
3
votes
3answers
5k views

How to recursively list all files with timestamps and full path?

I want to recursively list all files in a given directory, with their full path and their timestamps. Something like this: 10:30 Dec 10 2010 /tmp/mydir/myfile I've tried with: find . -type f -exec ...
46
votes
2answers
14k views

Icon? file on OS X desktop

When I ls my Desktop from terminal (by using ls ~/Desktop), I see a file named Icon?. As far as I can tell, it's empty (nano Icon? shows nothing). It doesn't show up on my actual Desktop, and open ...
-1
votes
1answer
44 views

ls: show date of last updated file in directory tree, for each directory/file in list

I am looking for parameters to ls, or something equivalent, that do the following for a specified directory: For each subdirectory: Look at each file and directory it contains, recursively. Find ...
765
votes
8answers
540k views
1
vote
3answers
132 views

cd to most recently modified directory after ls -lt in one command

When i browse logs, i use ls -lt in order to see most recently modified folders. Is there a shortcut for entering this folder in one command? Perhaps pipe to other command will do the trick? For ...
0
votes
1answer
21 views

Find last edited directory in a bash script

I have been told never to parse ls, but I would like to use the last edited directory in myDir as a variable in my bash script. I know I could capture this via ls -ltr myDir | tail -n1 | awk '{print ...
1
vote
1answer
34 views

Alternative to ls to group extensions before sorting

I'm looking for some way to modify/replace ls with a command that is capable of: Grouping directories first (as ls does) grouping files by user-defined extension groups (e.g., all image-type ...
8
votes
2answers
10k views

How to `ls` a remote folder?

This one uses Samba: $ ls smb://192.168.5.4/wdtvlivehub/abc ls: cannot access smb://192.168.5.4/wdtvlivehub/abc: No such file or directory I somehow managed to do it by; Browsing to the remote ...
6
votes
2answers
1k views

Mac OS X: Is there a straightforward way to color ls output according to Finder label colors?

I have a client with a directory tree that has a number of high-level directories that I need to have on my local development machine. I rarely look at them unless something goes awry. I've marked ...
11
votes
1answer
4k views

Making ls aware of “hidden” file flag

Is it possible to make ls aware of the hidden file flag on Mac OS X? Currently, a simple ls -lO produces: $ ls -lO total 0 drwxr-xr-x@ 84 danielbeck staff - 2856 29 Mai 22:44 Applications ...
0
votes
1answer
145 views

ConEmu + ls — 256 colors not working

I'm using ConEmu (specifically Cmder's version). Running 'cmd', it supports 256 colors (top). However, I can't get other programs to run in 256 color mode. I've tried Perl (middle) and ls (bottom), ...
0
votes
1answer
46 views

Displaying unicode emoji in filenames on Ubuntu

I'd like to use emoji in filenames and access them on the command line, but I can't seem to get it to work with ls. Weird thing is, if I pipe into just about any other program, the emoji are correctly ...
8
votes
2answers
29k views

How to find all soft links (symbolic links) in current directory?

Question relates to shell-scripting in bash. How to check with a script which files within the current directory are soft links? In case I have used the wrong term, when I say soft links, I am ...
1
vote
2answers
71 views

how to make ls show hidden files then directories then regular files in order

Is there a way to get ls to show all dot files including hidden directories first then regular directories then regular files? I have read throughout the ls man page but come up with nothing. I have ...
158
votes
3answers
7k views

On OS X, why does `sudo ls` show hidden (dot) files?

With OS X Yosemite, using the following commands, I get the following: $ touch .a $ touch b $ /bin/ls b $ /bin/ls -A .a b $ sudo /bin/ls .a b It shows hidden files (that have names starting with ...
0
votes
2answers
28 views

LS but exclude suffixes

I have files foo.mp3 bar baz.mp3 bar baz 2.mp3 What command would output the following? foo bar\ baz bar\ baz\ 2 I know ls -1b handles the escapes, but how do I cut ...
1
vote
0answers
74 views

How to ls -l file from output of grep

I was trying to run the following command: ls -lh `grep -E "^log4j.appender.File" /var/domains/*/servers/*/logs/log4j.properties | sed 's/.*=//g'` but it shows me error: ls: cannot access ...
1
vote
2answers
556 views

Meaning of starting d and starting l in drwxr-xr-x and lrwxr-xr-x

There are two files with the permission strings drwxr-xr-x and lrwxr-xr-x. I was wondering what the starting d and starting l stand for?
55
votes
10answers
42k views

How to sort first directories then files etc… when using “ls” in Unix

I would like to use ls command to first show direcotries and then files. I tried ls -la | sort -k 1 But I got a wrong order.
0
votes
0answers
132 views

How to configure dircolors in Cygwin

I've been trying to customize the appearance of the ls command in Cygwin, but have not been able to get the dircolors command to work properly. I am was following the steps found in this tutorial. ...
0
votes
0answers
18 views

Filter permissions ls by directories normal users don't have read/execute access

I want to generate a list of directories within usr/bin/ that normal users don't have read/execute access to. I know I can use the 'find' command but don't know how to make it work to display what I ...
0
votes
0answers
49 views

Cannot see files present on server when connecting via Filezilla / SFTP

I am not able to see the files present on the server using Filezilla ftp client. I am using SFTP connection. I am able to connect to the server. I can see only the directories but not the files. ...
2
votes
0answers
43 views

How to get fish-style formatting with less

Let's say I run a command like ls in fish and get lots of output, how do I scroll through it and still keep the fish formatting or something like it? ls | less doesn't keep the formatting. I know ...
6
votes
3answers
180 views

Linux: How could a directory be created without “.” and “..”?

I am not sure if the following issue is specific to busybox: I have an embedded device with busybox installed. From what I understand, when a directory is created, usually 2 hidden files will be ...
0
votes
0answers
115 views

Cannot start Tomcat server from Mac terminal?

I am trying to start the Tomcat server on my Mac. When I navigate to the bin folder, the startup.sh file is there but when I try to run it, it says the file doesn't exist: quickCoder-MacBook-Air:bin ...
1
vote
2answers
91 views

Ordering of filenames in linux - not purely lexicographical?

Given a few files in a directory data the following ls command provides a surprising result in the sense of how they are ordered: for f in data/*; do echo $f; done ...
10
votes
4answers
7k views

How to list files recursively and sort them by modification time?

How do I list all files under a directory recursively and sort the output by modification time? I normally use ls -lhtc but it doesn't find all files recursively. I am using Linux and Mac. ls -l on ...
4
votes
4answers
11k views

Recursively list full absolute path of files with permissions in Linux

I have done a bit of searching online, and I am trying to find a way to recursively list all files with their absolute path and with their permissions. I want to do this so that I can grep out what I ...
1
vote
1answer
98 views

ls colors disappear after running zsh

I installed the latest version of zsh on my osx using brew and then went ahead and installed oh-my-zsh. Everything is fine and dandy, but where did my ls colors go? If I run a bash -l inside of that ...
1
vote
2answers
191 views

Alternative to 'ls -A' in Bash

Is there an alternative to ls -A command in native bash functions? Wildcard * isn't the same. I tried hard to find one, but echo * doesn't show hidden files.
5
votes
4answers
883 views

How to turn off --classify option in ls command?

My ls command is aliased to have certain options automatically applied, including --classify (same as -F) Normally this is fine and I don't want to screw around with my .bashrc file. Just this one ...
45
votes
7answers
77k views

How to list folders using bash commands?

Is there any way to list just the folders in a directory using bash commands? ( as the ls command lists all the files and folders )
1
vote
2answers
51 views

Finding php files that have numbers in the filename

Can someone help me with a command line to find all .php files on a server with a number in the filename? I have searched, as best I can, for other answers, but they typically show for a specific ...
5
votes
3answers
2k views

is there a way to read the cumulative size of all files in a folder?

I want to read the size of a folder from the command line. ls -lh shows all folders as being 4k, which presumably is the size of the footprint of the folder itself, rather than the contained files. ...
10
votes
3answers
867 views

What does third symbol in “rw-” file mode mean in OS X ls manual page?

I have trouble understanding ls's manual regarding a file that has rw- mode. Here's the quote: If r, the file is readable; if −, it is not readable. If w, the file is writable; if −, it is ...
7
votes
3answers
562 views

Bash: ls * without folder grouping

If I type: ls source/* source/fonts: fontello source/images: bg1.png eng.png fra.png I get the list of files, grouped by folder names. How can I simply get the list of ...
0
votes
0answers
51 views

Why “ls” command highlights some folders?

Why LS highlights folder PyFac ? How disable this highlighting? IMG My .profile: if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi export CLICOLOR=1 ...
0
votes
1answer
62 views

When in ~ directory, why doesn't ls show /usr/ directory?

I can cd /usr/, but why doesn't ls -a or ls -d or ls -d */ show me that the usr directory is there? I have already seen this question, but ls -d */ yields ls: cannot access */: No such file or ...
8
votes
2answers
3k views

Vi can write to file despite file being read-only

The following example show how to create a file with only read permissions. As we can see, when I try to write to this file using the echo command I get, Permission denied. But why, in the case that ...
-2
votes
1answer
2k views

ls -ltr command in UNIX and Linux - Behaviour

Why does ls -ltr show different total? We have same files in both unix and linux environment please refer BELOW UNIX > ls -ltr /A/B/C/ total 2140 -rwxr--r-- 1 demo demo 14415 May 30 ...
0
votes
1answer
458 views

ls linux command: how to filter files in other directories

I know what ls folder/ and ls *abc* do in linux. I want to filter out some files in a specific folder. I tried this: ls folder/ *abc but it does not return correct values. Any idea? Thanks