The ls command lists the contents of a directory.

learn more… | top users | synonyms

4
votes
2answers
718 views

Tell if a folder/file is hidden in Mac OS X

I know you can set or unset the hidden flag of a folder/file by doing chflags hidden foo.txt and chflags nohidden foo.txt. But is there anyway of telling whether the folder/file is currently hidden ...
4
votes
2answers
3k views

How to list ALL directories according to their size? [without including the parent directory]

I have a bunch of random folders, some of them are hidden (beginning with a period). I want to list all of them, sorted by their sizes. I have something on the lines of this in mind: ls -d -1 -a */ ...
4
votes
3answers
122 views

ls on device without mounting it

Is it possible to run ls on a device without mounting it first? Something like this: # ls /dev/sda1
4
votes
4answers
243 views

linux + how to ignore (filter) file with space

Sometimes a file name is created from a couple of names and space between each name as the following: $ touch "A B C" $ ls A B C <-- one file but has three words ! ...
4
votes
2answers
343 views

Get the complement of the result of an ls command

Let's say I have a directory with multiple files, all of which are either binary files (files with no declared extensions) and source files (.c extension). I do this: $ ls and get: README.md ...
4
votes
4answers
5k views

List symlinks in current directory?

This question talks about finding directories in a current diretory. The solution is basically: ls -d */ That's great but how can I easily list symlinks? Do I have to use something like find . ...
4
votes
3answers
3k views

list full path of file without tying it from relative relative path

I could do this root@server [/home/user/public_html]# ls /home/user/public_html/.htaccess but I'd like to do this ls --switch .htaccess /home/user/public_html/.htaccess is it possible?
4
votes
4answers
318 views

List any file ending with .in and corresponding .out with shell script

I have a directory full of files ending with different extensions, how would I list/select only the files ending with .in and corresponding .out that share the same basename? e.g. file1.txt file1.in ...
4
votes
5answers
1k views

Strange case: Text file that exist and doesn't exist

I'm completely puzzled about a problem with a single plain text file in my system fedora 12. I used a known software in bioinformatics, maker, to produce lots of plain text files and one of them it ...
4
votes
2answers
1k views

What's the difference between “s” and “S” in ls -la?

When I ls -la, it prints many attributes. Something like this: -rwSrwSr-- 1 www-data www-data 45 2012-01-04 05:17 README Shamefully, I have to confess I don't know the exact meaning of each ...
4
votes
4answers
1k views

file $(ls /usr/bin/* | grep zip) command gives me errors. What's wrong?

I'm a total noob when it comes to unix/linux commands and I decided to read a book. I've reached a chapter where they try to explain how to pass the output of commands as expansions to the shell. ...
4
votes
2answers
526 views

Tmux eclipsed colorized output of ls

I'm running Xubuntu 12.04, and when I use the Terminal I get colored filenames from ls. But inside tmux, everything ls prints is white. I know my tmux supports color, though, because I get color ...
4
votes
2answers
169 views

Sort files by modification time

I've seen many questions and answers here using a construction along the lines of list_dir=`ls -t /path/to/dir/` for i in $list_dir; do or ls -t | while read i; do Now, I know that you shouldn't ...
4
votes
3answers
2k views

How can I display octal notation of permissions with ls - and can octal represent all permissions? [duplicate]

After looking at the man page for ls on my system and searching Google, I see there IS a hack of way to use awk or perl to show octal permissions when using ls, but with bash is there anything more ...
4
votes
2answers
787 views

How can I search for a file with fixed name length using ls?

In a directory, I have files like lazer_100506 lazer_100707 lazer_091211 lazer_110103 lazer_100406_temp lazer_100622#delete etc How can I get a listing of only the first four files? $ ls ...
4
votes
3answers
1k views

Sorting files according to size recursively

how to scan a folder recursively and find the largest files in the folder, and sort them by size. I have tried using ls -R -S but it tends to list the directories as well I need to scan the folders ...
4
votes
2answers
490 views

how to use grep for specific files?

for example I type ls -altr | grep "23 Dec" so it will show files for 23 Dec only and I want to use grep for them, like ls -altr | grep "23 Dec" | xargs grep -l "some_string" but this doesn't ...
4
votes
2answers
262 views

'ls -l' file timestamp format

When I issue the command: ls -l The file/directory modification timestamp column (specifically the month part) is displayed in the native language of the country I'm based in instead of English. ...
4
votes
2answers
357 views

Find/ls caching

It seems as though the first time I run find or ls on a directory, it takes a while to work. But, each time thereafter, it is fast, as though a list of the directory's contents has been cached or ...
4
votes
1answer
470 views

What does the “@” (at) symbol mean on OSX ls? [duplicate]

When I check permission of less files from the command line on my Snow Leopard OSX system using Bash I see -rw-r--r--@ for certain files and for others I just see -rw-r--r-- What does the @ mean here? ...
4
votes
1answer
558 views

Pass colors from ls through pipe to awk 'print' statement

This is a follow-up to my question from yesterday, Show sum of file sizes in directory listing. Thanks to Zero Piraeus and a point in the right direction by Mauritz Hansen, I now have function ...
4
votes
3answers
2k views

what is total in the output of ls command [duplicate]

Possible Duplicate: ls command: what does the first line mean? I have an empty directory.I am using following command to view the contents of that directory. ls -lart The output I get is ...
4
votes
1answer
3k views

How can I use `find` and sort the results by mtime?

I want to use find but sort the results reverse chronologically as with ls -ltr. Is this possible through any combo of flags or pipelines?
4
votes
1answer
927 views

copying device nodes

I'm trying to transfer a working Linux installation to a new larger disk, so I've attached the new disk on a USB port, partitioned it and created filesystems. While copying all the files over I hit a ...
4
votes
1answer
277 views

Set ls color listings based on regex instead of globbing

Is it possible to set regex patterns for color matching in the LS_COLORS variable? So instead of just *.jpg=38;5;220 Can I do \.(jpg|gif)=38;5;220 That's just an example, I'd like to get more ...
4
votes
1answer
40 views

ls -l --group-directories-first (act on symlinks as well)

ls option --group-directories-first causes directories to be listed on the top, which makes the output of ls nice and clean: ls -l --group-directories-first However, it does not act on symlinks, ...
4
votes
3answers
127 views

What could be the use case of changing modified time of a file to the future?

I was reading through the man page of ls on UNIX, specifically OS X Mavericks. This got me intrigued: If the modification time of the file is more than 6 months in the past or future, then the ...
4
votes
3answers
288 views

How to inspect group permissions of a file

I would like to inspect group permissions of a file from a bash script. Specifically, I need to check whether a file has the group writeable bit on. That's it. Simple as that. However: I also need ...
3
votes
3answers
896 views

Using OR patterns in shell wildcards

Contents of my dir are $ ls -lrt total 0 -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 night.txt -rw-r--r-- 1 user1 admin 19 Oct 8 12:31 noon.txt -rw-r--r-- 1 user1 admin 38 Oct 8 12:31 day.txt I ...
3
votes
2answers
2k views

List of Recently Modified Files

How can I Get a list of all files modified , say 3 months ago. I checked this question but I was not able to apply it to my scenario. I am trying this now , it seems to be working , but I know there ...
3
votes
2answers
685 views

How can I stop ls from descending into directories, similar to prune for find?

If I type ls *ro* I also get files in subdirectories that match the *ro* pattern. Is there any option for ls similar to prune? Ideally a flag, otherwise perhaps an exec?
3
votes
4answers
7k views

Argument list too long for ls

I get the following error when trying to ls *.txt | wc -l a directory that contains many files: -bash: /bin/ls: Argument list too long Does the threshold of this "Argument list" dependent on distro ...
3
votes
4answers
1k views

List all files / binaries in current PATH

Is there an "easy" way of running an "ls -la" style command for listing all files / executable binaries in the current PATH? (I intend to pipe the output into grep, for looking for commands with ...
3
votes
2answers
1k views

List subdirectories only n level deep

Festival stores voicepack data in the following example directory structure: /usr/share/festival/voices/<language>/<voicepack name> What is the simplest one-liner (preferably using ls) ...
3
votes
5answers
359 views

How can I concatenate a single column of output into a list?

I'm using: ls /proc | grep -v "^[0-9].*" to get a list of all the files and directories in /proc that don't begin with numbers. The output is a single column list, i.e.: acpi asound buddyinfo bus ...
3
votes
1answer
534 views

`ls` command does not list latest directory contents

The Linux shell does not print up-to-date information when it comes to ls. For example I use my other processes (IDEs etc) to create some directories. However when I run an ls command I don't see ...
3
votes
3answers
3k views

How to search and replace text in all php-files in a directory and it's subdirectories

I am looking for a shell script that recursively traverses all .php files in a directory and performs a search & replace of a particular text pattern. The search pattern is quite long ( > 5000 ...
3
votes
2answers
796 views

recursive 'ls' giving absolute filenames

When I do 'ls -R' in a directory, I get something like ./dir1 dir2 file1.txt file2.txt ./dir1/dir2 file3.txt file4.txt but I would like a command that gives me ./dir1/file1.txt ./dir1/file2.txt ...
3
votes
1answer
3k views

+ or @ mark after running 'ls -al'

In Mac OS X, run 'ls -al' gives me something like this. drwxrwxrwx+ 4 smcho staff 136 May 5 09:18 Public drwxr-xr-x+ 6 smcho staff 204 Feb 1 2010 Sites drwxrwxrwx 9 smcho staff ...
3
votes
2answers
73 views

dircolors: rules for _ext (rather than .ext)

In UNIX, many file extensions do not contain the dot in front, as in bashrc rather than bash.rc or ssh_config rather than ssh.config I would like to add dircolor rules for _config as well. However, ...
3
votes
1answer
317 views

What do the symbols displayed by ls -F mean?

I noticed that if I run ls -F on a directory, some of the entries have a * or a @ after them. spuder@ubuntu:~$ ls -F /sbin acpi_available* getpcaps* lvmconf* ntfscp* ...
3
votes
2answers
465 views

Total in `ls -l`

When I run ls -l, the following is displayed: >: ls -l total 320 -rw-r--r-- 1 foo staff 633 5 Apr 13:23 A.class -rw-r--r-- 1 foo staff 296 5 Apr 13:24 A.java ... What does the ...
3
votes
2answers
138 views

How do I create a structured list of all the files and directories under a particular directory (recursively)?

I need to have an "image" of a file system without actual contents of the files - just all the names and the structure, so that I can read the file and know what files were stored there and how were ...
3
votes
2answers
109 views

Executables show with character * next to their name in output of ls

I noticed that when I list my executables with ls on my Z shell they show up with a character * next to their name (e.g. see the file in red .test_color_scheme)     What is causing ...
3
votes
1answer
33 views

Customize bash to always include a certain parameter

When using the "ls" command, bash prints in the following format: file1 file2 file3 file4 file5 file6 file7 file8 But when given the parameter "-1", it prints: file1 file2 file3 etc... Is there ...
3
votes
3answers
145 views

Why do ls and hexdump disagree about my file size?

I have a file I created (in vim), for testing purposes (testing UTF-8 output in an SSH client). Odd things, however, are happening to this file. I wondered what bytes were in the file, so I used ...
3
votes
1answer
55 views

Why aren't CD image files listed when mounted in current directory?

When mounting a disk image in the current directory using : sudo mount -o loop -t iso9660 wall.iso ./ Listing files in current directory only returns wall.iso . To view the actual files on the disk ...
3
votes
2answers
484 views

Why is bash giving me (apparently) conflicting information about a file?

Background I am working on a RHEL 5 cluster. I want my Fortran program to read the file /home/bob/inputs/input_1 I asked Bob to give me permission to read all contents of inputs: [bob@server]$ ...
3
votes
2answers
1k views

How to solve sudo: unable to execute /bin/ls: Argument list too long

When I run this command from php sudo -u db2inst1 ls -t /var/lib/edumate/bdrs/*/*/daily/*NODE* | sort -r I receive sudo: unable to execute /bin/ls: Argument list too long ls lists all daily backup ...
3
votes
1answer
116 views

How to disable flashing file names in rlogin

I have a strange problem with my rhel 6.4 system. If I do a rlogin to any of my machines, all the files in the remore machine will be flashing and it is so annoying. Can somebody please tell me how ...