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

learn more… | top users | synonyms

26
votes
2answers
3k 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 ...
23
votes
3answers
8k 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 ...
14
votes
7answers
10k 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
3answers
8k 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
5answers
6k 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 ...
10
votes
8answers
33k 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 ...
10
votes
4answers
1k 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 ...
9
votes
2answers
481 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; = ...
8
votes
3answers
806 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
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 / ...
6
votes
3answers
303 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
532 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?
6
votes
2answers
3k 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
3k 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
252 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 ...
5
votes
3answers
632 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 ...
5
votes
2answers
8k 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
232 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
616 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 ...
4
votes
1answer
275 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
3answers
2k 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
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
544 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
690 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
2answers
266 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
4answers
648 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
1k 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
4answers
7k 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
1answer
174 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 ...
2
votes
2answers
3k 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 ...
2
votes
3answers
3k 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 ...
2
votes
2answers
147 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
313 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
243 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
41 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
2answers
3k 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
1answer
256 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
116 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
24 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
139 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
4k 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
95 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.
1
vote
3answers
60 views

Output Directory Contents to File

I have a directory html. I would like to output the files of the directory, including the path, to a file. You can do something like this with the command: ls -R scripts/html > out.txt But the ...
1
vote
3answers
2k views

List files of particular extension

Ok this is strange. I am using this code, ls *.prj To list all the files with the .prj extension in the dir but I am getting this error, bash: /bin/ls: Argument list too long I eventually ...
1
vote
1answer
582 views

Using alias to change ls to ls-l changes(or disables) the colors of ls output

I've used alias to change ls to ls -l, but the colours change to the normal font of the terminal (also tried ls -l before the alias command and the colours appeared fine). What is wrong? Thank you
1
vote
1answer
89 views

Why are “ls” and “stat” returning different ownerships for the same object?

This is in a continuation of question here I run this command as root user chown someuser:someuser /mnt/my-address and then # ls -l /mnt/my-address response is total 16 drwx------ 2 root root ...
1
vote
1answer
36 views

One command for ls and cat functionality?

Okay guys, this is an experimental question warning! I often confuse cat and ls when quickly working on the console. Not because I forget their meanings, no. Just because I type without deeply ...
1
vote
1answer
187 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 ...
1
vote
1answer
698 views

Preserving multi-column output from ls when paging

By default, ls displays its output in multiple columns, but when it's sent to a pager such as less it's reformatted as a single column. Is there any way I can page the original, multiple-column output ...