Questions relating to the Linux 'list' command (ls)

learn more… | top users | synonyms

26
votes
2answers
4k views

Why does ls -l output a different size from ls -s?

I can't figure out why I'm getting the following results: ls -l tells me the size of a given file (HISTORY) is "581944": $ ls -l HISTORY -rw-rw-r-- 1 waldir waldir 581944 Feb 22 10:59 HISTORY ls ...
25
votes
3answers
10k views

Difference between 'dir' and 'ls' terminal commands?

I've been trying to find the difference between using the dir and ls commands in terminal. I know ls is the traditional unix method of viewing the files in a directory, and that dir is the windows ...
15
votes
8answers
47k views

How to move multiple files at once to a specific destination directory?

I got a bunch of files in some directory (along with many other files) that I want to move. Luckily, all the files I want to move contain a certain identifier in their names, so I can ls | grep ...
15
votes
7answers
13k views

How to list all the files in a tree (a directory and its subdirs)?

For a task of mine I need to list all the files in a tree (a directory, all its subdirs, all subdirs of those, etc.). I'd prefer to see them in Nautilus or Krusader, but a command-line solution is ...
12
votes
5answers
7k views

In the output of 'ls -n', what does the the second column mean?

When I run: ls -n I get something like: -rwxrwxrwx 1 1000 1000 765528 2009-10-15 18:41 file1 drwxr-xr-x 10 1000 1000 4096 2010-12-07 20:50 dir1 drwxr-xr-x 3 1000 1000 4096 2010-10-24 ...
12
votes
3answers
9k views

How to activate pagination for ls command?

What is the equivalent option for the ls command to activate pagination as in DOS the dir /p does?
11
votes
4answers
2k views

What is the significance of '*' (star, asterisk) in the file listing results?

I have noticed that some of my files have an asterisk at end. Does the asterisk at the end have any particular significance? I think they are mostly executable and displayed in green by the ls ...
10
votes
2answers
613 views

What are = and | in the output of “ls -F”?

I am working on creating a 'cheat sheet' of shell commands. I am currently researching the ls command and its flags. For the -F flag I know what the majority of the appended indicators mean but for; = ...
9
votes
8answers
2k views

How to show only hidden files in Terminal?

I have a directory that contains thousands of files, some of them are hidden. The command ls -a list all files, including hidden ones, but I need just to list hidden files. What command should I ...
8
votes
3answers
907 views

Tell `ls` to sort by regular ASCII codes, not “intelligently”

I have a couple files and ls sorts them like this: a _b c but I want to have _b a c How can I do that?
8
votes
2answers
648 views

What does the l command do?

There is a command l available on my machine which appears to do nothing. which l also produces no output. Is this a real command, and does it actually do anything?
8
votes
4answers
2k views

How to find all PDF files in directories and their subdirectories?

I want to list all PDF files in the directories of the current working directory. What command can do this? I remember a combination of ls and */*.pdf but don't remember what exact combination.
8
votes
2answers
2k views

What is the double slash (//) directory?

I mistakenly typed cd // instead of cd /. To my surprise, current directory showed up as //. What is that directory? Why does it exist? apple@snipped $ pwd /home/apple apple@snipped $ cd / ...
7
votes
3answers
120 views

List files appended with an order number

Is there a quick way to list all the files from a location having an appended order number? something like: ls -a generates the result: 1 file a 2 file b ... 100 file whatever Thanks. P.S. ...
7
votes
3answers
1k views

List all files that do not have extensions

I want to list all files in a directory that don't have extensions. For example: $ ls a.txt b c.pdf d e.png $ ls -someOption b d What command I can use instead of ls ...
6
votes
3answers
367 views

How do you get details from the output of the locate command?

When I run the ls -l command I get details about the files in the current directory like permissions, owner, group, file size. Is there a way I can get these same details instead of just the ...
6
votes
2answers
4k views

Is there a way to do a ' ls -R | grep “aname”* | rm; to remove multiple files in multiple directory

I have installed (compiled) emerald. The command make uninstall didn't work (there is no makefile as it is just a script). So I decided to remove the file manually. But there were a lot of files. ...
6
votes
2answers
4k views

Best way to list 100 first files in a directory sorted by time

What would be the best way to list 100 first files in a directory sorted by the created timestamp (oldest first). The directory is quite large (around 100000 files). ls piped to head takes an awful ...
6
votes
1answer
275 views

automatically run ls after changing path using autocd

So everytime I change the directory I would like the new path to automatically get listed with ls.There are solutions if the path gets changed using cd but I never found a solution that would work ...
6
votes
3answers
1k views

Can ls -l be made to separate fields with tabs rather than spaces to make the output useful in a spreadsheet?

How can the output of ls -l be modified to separate fields using tabs instead of spaces? I want to paste the output into a spreadsheet; the padding with a variable number of spaces makes it difficult ...
5
votes
2answers
9k views

How can I direct a pipe input to ls command?

When I type sth. like that find . -name *foo* | ls -lah it gives me a ls-output of 'pwd' like I had no file(s) given to 'ls'. To simply use ls -lah $( find . -name *foo* ) works well (when the ...
5
votes
2answers
259 views

Colorize hardlinks in ls output?

How can I colorize hardlinks myself? Turns out on an old Ubuntu 10.04 I have, this happens by default (same .bashrc and .profile in use), whereas on the newer Ubuntu 12.04 it doesn't. This is the ...
5
votes
3answers
3k views

change default command options

When I enter command ls I see a list of files and directories in current directory, the list displayed is quite annoying. Rather, I like to execute ls command with -1 option like ls -1 My ...
4
votes
2answers
4k views

Why doesn't this wildcard work the way I expect?

On my user folder, I have folders like D ropbox, D ocuments, D ownloads & d ump. ls a* should list all the files whose name starts with a. Right? But when I gives the command ls d*, instead of ...
4
votes
6answers
1k views

Count total number of files in particular directory with specific extension

I want to count the total number of files in particular directory that ends with ".mp4" extension. I am getting following command: ls -F |grep -v / | wc -l It count all the files in particular ...
4
votes
1answer
311 views

Nautilus sort order with ls

I am creating image sprites and have neatly named around 100 files. I am using the following to generate an image sprite from individual images: convert $(ls -w 1000) +append sprite.png I have just ...
4
votes
1answer
1k views

Why does ls -lh give me ls: invalid option — 'h'

I'm using Interpid (I know I need to upgrade). When I try and use the -h option with ls I get an error. I swear this used to work, and the man page says it should. Any ideas? $ sudo ls -lh ls: ...
4
votes
3answers
792 views

create a list of files located in multiple directories

I have a set of data files (*.all) located in different folders Documents/rawdata/Geob1005/1.all, 2.all, 3.all,...,n.all Documents/rawdata/Geob1006/A.all, B.all, C.all,...,Z.all and so ...
4
votes
1answer
734 views

Summarize file sizes of a directory structure?

I have written a small backup script with rsync. I would like to monitor its progress by comparing the total file sizes on the source and destination directories. du Is inaccurate because it measures ...
3
votes
4answers
15k views

How to Search for Files Recursively into Subdirectories

I am trying to look for all XML files in a particular directory and all sub-directories (recursively) inside it. ls -R *.xml is only listing files in the current directory. I am quite sure, the ...
3
votes
2answers
300 views

“ls” with one-digit pattern gives me strange results

I'm running Ubuntu as VM in VMWare Fusion on MacPro: ayakovlev@ubuntu:~$ uname -a Linux ubuntu 3.11.10.3 #1 SMP Thu Mar 6 15:31:54 EST 2014 x86_64 x86_64 x86_64 GNU/Linux The command below outputs ...
3
votes
1answer
154 views

exclude certain files in ls

I would like to run ls and exclude certain files in the output. When I run the following command, I get all files with each on one line: $ ls -1 file1 file2 file3 temp I would like to run this ...
3
votes
4answers
901 views

What's the easiest way to remove the “total <size>” line from the output of ls -l?

The best I could find via Google/man ls was: ls -l | grep -v '^total' Is there something I'm missing in the flags to ls? Also, why is the total size in kb, regardless of the -h flag? scratch that, ...
3
votes
4answers
15k views

listing files in a directory without listing subdirectories and their contents in that directory

I want to create a list of all the files in a directory, without listing any of the subdirectories that reside in that same directory, and print that list to a new file. ls -d * > filelist will create ...
3
votes
4answers
2k views

Can I use ls -R to show up to 2 folder depth?

I have a folder tree that looks like this main/ main/34532-23423632-2354/what-i-want/sth/other/blah-blah main/54634-56345634-3422/what-i-want/sth/ .... ...
3
votes
1answer
191 views

Directory permission

I am running 12.04 x64 server on ext4 disk. There are two user groups 'A' and 'B'. For a specific directory, I would like to give its all permissions to user group 'A'. Also I would like to give only ...
3
votes
0answers
113 views

ls on home directory very slow

A while ago, I accidentally created hundreds of thousands of files in my home directory which I subsequently deleted. Since then however, running ls in my home directory has been extremely slow ...
2
votes
2answers
189 views

How can I list the files in other (non-current) directory?

If ls lists the content of the current directory, is there a similar command that list the content of a non current directory, without using cd?
2
votes
2answers
173 views

ls system command not showing terminal colors

I've just been fooling around with some code in C, an example of a really basic program is as follows which just, obviously, lists the directories using the ls system command. #include ...
2
votes
2answers
313 views

How to make ls produce ISO 8601 format

In older versions of Ubuntu, like 9.10, ls(1) produced ISO 8601 format by default, in the way ls -l --time-style=long-iso does it. With 12.04, we're back at the older Unix style. Thus replacing ...
2
votes
2answers
4k views

How to list text files without a .txt file extension?

For example, how can I replicate ls *.txt when my text files are missing the .txt ending, and as far as extensions go appear the same as many other types of file? Alternatively, is it possible to ...
2
votes
2answers
477 views

use output from alias command as filename to open in vi

I set up an alias this morning to help finding the latest log file in a directory. My alias looks like alias latest="ls -lat | grep ^- | awk '{print \$8}' | head -1" In my research so far this ...
2
votes
1answer
272 views

subshell ls -lh “$(find /music -type d)” doesn't return list, instead results of find command

I'm trying to list the details of all the directories in my music folder using the following command: ls -lh "$(find /music -type d)" However all I get is the return of the find command. Is this ...
2
votes
2answers
46 views

Independence between sudo and the instruction it receives as an argument

I don't understand why the directory dir1 isn't shown with the same colour. Although this may look unimportant, it seems to me that this is a violation of the so oftenly mentioned principle of ...
2
votes
1answer
387 views

List files that were changed between a certain datetime [duplicate]

Possible Duplicate: How to remove files modified between particular dates? How can I list all files recursively in a directory that were changed within a certain timespan? like between ...
2
votes
2answers
244 views

Using ls and cd comands on network folders

Super-new linux/terminal user here- Is it possible to use ls and cd comands directly on directories within a public folder on a NAS, or does the share need to me mounted within the root directory ...
2
votes
1answer
30 views

How can I group the files in a directory based on their file size

I have a directory where I am writing lots of files but I know each of them fall under one of the 3 pre-determined memory sizes based on what I write. Any file I write may be either 300KB or 129.1MB ...
2
votes
0answers
190 views

after ssh session : -bash: /bin/ls: no such file or directory

I've logged into my Ubuntu server from work via putty under Windows. Right away I noticed something weird. I could not use the ls command. Got: -bash: /bin/ls: no such file or directory I didn't pay ...
1
vote
6answers
5k views

How to enter every directory in current path and execute script

I want to enter every directory retuned by ls command and execute script. I tried this (and many other things), but it just does not work ls | awk '{print $1" && pwd"}' | xargs cd How to ...
1
vote
2answers
123 views

ls command without username?

I want to use ls --full-time -lnG but do not wish to list the user names at all. Is there any way to do this? I would consider -n and -G optional if it is conflicting with getting this done.