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
98
votes
8 answers

How do I list all the files in a directory and subdirectories in reverse chronological order?

I want to do something like ls -t but also have the files in subdirectories included. But the problem is that I don't want the output formated like ls -R does, which is like this: [test]$ ls -Rt b testdir test ./testdir: a I want it to be…
dan
  • 43,914
  • 47
  • 153
  • 254
98
votes
13 answers

How to get file creation date/time in Bash/Debian?

I'm using Bash on Debian GNU/Linux 6.0. Is it possible to get the file creation date/time? Not the modification date/time. ls -lh a.txt and stat -c %y a.txt both only give the modification time.
NoodleFolk
  • 1,949
  • 1
  • 15
  • 24
80
votes
6 answers

Listing the content of a tar file or a directory only down to some level

I wonder how to list the content of a tar file only down to some level? I understand tar tvf mytar.tar will list all files, but sometimes I would like to only see directories down to some level. Similarly, for the command ls, how do I control the…
Tim
  • 1
  • 141
  • 372
  • 590
80
votes
2 answers

Is there a way of listing the contents of the local directory in ftp?

lcd changes local directories. ls lists files on remote directory. What I would like is lls, to list files on local directory. Is this possible? I know I can always open another terminal to do this, but I'm lazy!
Jacko
  • 12,665
  • 18
  • 75
  • 126
78
votes
11 answers

List files not matching a pattern?

Here's how one might list all files matching a pattern in bash: ls *.jar How to list the complement of a pattern? i.e. all files not matching *.jar?
calebds
  • 25,670
  • 9
  • 46
  • 74
72
votes
3 answers

Cygwin - command not found

Running bash commands in cygwin produce the following error: $ ls ls: command not found This is a question that I self-answered on my tech blog where I keep the tech-tips which I need to give to myself from time to time, so I decided to move it…
Sudipta Chatterjee
  • 4,592
  • 1
  • 27
  • 30
70
votes
2 answers

Windows equivalent for Unix find command to search multiple file types

While having a cygwin installed in windows gives most of unix command, still i was wondering how to search multiple filetypes in one command using windows "find" command. ie: find . -name *.cpp -o -name *.h -o -name *.java The above command gives…
Soumen
  • 1,006
  • 2
  • 12
  • 19
69
votes
6 answers

first two results from ls command

I am using ls -l -t to get a list of files in a directory ordered by time. I would like to limit the search result to the top 2 files in the list. Is this possible? I've tried with grep and I struggled.
Fidel
  • 7,027
  • 11
  • 57
  • 81
66
votes
3 answers

Unix pipe into ls

I thought I understood *nix pipes until now... I have an executable called studio which symlinks to my install of Android Studio and I had assumed I could get the linked-to location with which studio | ls -l But that doesn't work. What it gives me…
hcarver
  • 7,126
  • 4
  • 41
  • 67
65
votes
8 answers

Show full path when using options

I often use this list command in Unix (AIX / KSH): ls -Artl It displays the files as this: -rw-r--r-- 1 myuser mygroup 0 Apr 2 11:59 test1.txt -rw-r--r-- 1 myuser mygroup 0 Apr 2 11:59 test2.txt I would like to modify the command such a way…
TechnoCore
  • 1,394
  • 2
  • 16
  • 21
63
votes
9 answers

'ls' is not recognized as an internal or external command, operable program or batch file

'ls' is not recognized as an internal or external command, operable program or batch file. I get this error when I try to glance at the files of my folder. cmd opened regularly(not as an admin). I've recently downloaded anaconda for python.During…
Kalpit
  • 845
  • 1
  • 7
  • 13
60
votes
4 answers

pass output as an argument for cp in bash

I'm taking a unix/linux class and we have yet to learn variables or functions. We just learned some basic utilities like the flag and pipeline, output and append to file. On the lab assignment he wants us to find the largest files and copy them to a…
Yamiko
  • 5,303
  • 5
  • 30
  • 52
55
votes
19 answers

Quick ls command

I've got to get a directory listing that contains about 2 million files, but when I do an ls command on it nothing comes back. I've waited 3 hours. I've tried ls | tee directory.txt, but that seems to hang forever. I assume the server is doing a…
Mark Witczak
  • 1,563
  • 2
  • 14
  • 13
53
votes
3 answers

How to display column headers for 'ls -l' command in unix/linux?

I want to display all the column headers when I type ls -l command in bash shell in unix/linux When we type ls -ltr on command prompt we get something like the following. -r--r--r-- 2 makerpm root 1898 Jan 28 14:52 sample3 -r--r--r-- 2 …
sunil_rbc
  • 772
  • 1
  • 8
  • 13
53
votes
3 answers

Command to list all files except . (dot) and .. (dot dot)

I'm trying to find a command that would list all files (including hidden files), but must exclude the current directory and parent directory. Please help. $ ls -a \.\..
nondoo
  • 601
  • 1
  • 5
  • 13
1
2
3
87 88