The ls command lists the contents of a directory.

learn more… | top users | synonyms

1
vote
1answer
31 views

ls --color=auto (dir colors) not working in one directory

I changed ownership of a folder to provide restricted access to some users (it previously was only visible to root) and after that, all files are now one color (bright green) and directories are blue. ...
0
votes
1answer
18 views

How to create a file name for the pipeline to delete all files?

So I want to delete all files in my current directory using the following pipeline: ls | sed -rn 's/(.*)\.jpg$/mv -n & \1.jpeg/pi' | sh How to create a file, named so that running the above ...
0
votes
3answers
46 views

Number of files in a directory starting with specific text

How to get count of files in a directory starting with specific text like dataxxx.csv
2
votes
3answers
124 views

only show the source file and target linked file using `ls`

I can show the target file that a link points to using ls -l: snowch$ ls -l /usr/local/bin/mvn lrwxr-xr-x 1 snowch admin 29 12 Dec 08:58 /usr/local/bin/mvn -> ../Cellar/maven/3.2.3/bin/mvn Is ...
2
votes
3answers
325 views

List files that do not begin with a specific prefix

I need to list only the files in a directory that do NOT begin with qc_dl, qc_dt or qd_df, but that also DO end in .sas. I can list the files that do not begin with "qc_dl" as such: ls -I "qc_dl*" ...
1
vote
3answers
77 views

What does “>” do vs “>>”? [duplicate]

I am currently doing preparation for my GCSE computing controlled assessment on Linux. I type ls > list and ls >> list into the command line, but it does not do anything. I have googled it ...
0
votes
2answers
43 views

How can I capture two columns of ls output in a bash script

I want to create a script to delete any directories with numeric groups. What I have so far captures and analyzes the group: #!/bin/bash re='^[0-9]+$' for x in `/usr/bin/ls -l /var/indexes | sort ...
0
votes
3answers
62 views

Export file names of a directory to csv

I have a question regarding exporting folder names to a csv file. I have read already many entries in the web to such topics but on nearly all the topic was about exporting filenames and size and ...
0
votes
3answers
74 views

How to print only certain characters?

I have to translate the permissions of a file this way: r ► c w ► s x ► e Then, I must extract the group of characters which are related to owner group. Last step is to print that group of ...
0
votes
2answers
46 views

How can I recover disk space shown by the difference in disk usage between ls and du

I have a one Terabyte external hard disk drive that I intend (should have done this long ago) to use for backups, and I have done a lot of experimenting to get my mind round it. When I looked again ...
0
votes
1answer
44 views

How can I write an alias for cd such that it will fire ls after going into the directory to which I just cd'ed into? [duplicate]

Lets say I want to do cd home and then ls -lrth. I want these two things combined into a single command. I tried writing an alias, but it didnt work. Can you help me ?
2
votes
3answers
62 views

Remove files from listing that are created/modified on Saturday

I am not sure if it is possible. I do ls -l, it gives all the files in the current directory. Is there a way to say list only files that weren't created/modified on Saturday's with shell command?
2
votes
3answers
58 views

How to know list of directories under a filesystem?

If I run sudo df -h command, I got below output: Filesystem Size Used Avail Use% Mounted on /dev/sda2 12G 9.5G 1.1G 91% / /dev/sda4 3.8G 1.5G 2.1G 41% /home ...
1
vote
1answer
41 views

Ls -1 Command in linux on Ubuntu dosen't show details beside the name of each directory or file in the list? [closed]

I am using Ubuntu and when i issue this ls -1 command there is no details appear in-front of the directories and files names there is only a blank space ..what can cause this ?
0
votes
0answers
34 views

Failed to list directory contents: process waits infinitely

I use Linux Mint 13, and sometimes (rarely) I find myself not being able to list my home directory contents. When I try to do so: $ cd $ ls then, ls just waits indefinitely. The same with any other ...
2
votes
2answers
46 views

ls doesn't give me the same as cd + ls to the same folder

$> ls ../../../../.. Doesn't give me the same result as $> cd ../../../../.. $> ls Why? Something with links? What's going on? [ johanrj@jamin ] ...
4
votes
2answers
455 views

Basic commands in Unix not working i.e: -bash: ls: No such file or directory

I'm new to Unix and in the process of installing a program for my dissertation I must have played with the PATH for the basic Unix commands such as ls. Every time I type ls and the directory name I ...
3
votes
4answers
80 views

Determining the number of files and subdirectories in Linux

When displaying directories in linux using ls -ld, I get something like this: user@shell:~/somedirectory$ ls -ld drwxr-xr-x 2014 K-rock users 65536 20011-11-05 11:34 user@shell:~/somedirectory$ ...
1
vote
3answers
63 views

Print full pathname with `ls` and `find`

I want ls to print with absolute pathnames, how do I do that? find / -type d -mount -exec ls -ls {} \; ls is printing only the relative file names within the directory.
4
votes
6answers
282 views

How can I list files by type with ls?

When I use the ls command with the option -l, the first string of letters gives the info about each file, and the first letter in this string gives the file's type. (d = directory, - = standard file, ...
1
vote
2answers
81 views

how to sort files by their permissions using ls?

I have a large number of files and directories in one directory. I need to sort them in terms of the permissions. For example drwx------ drwxr-xr-x drwxr-x--- I am just wondering if we can sort ...
3
votes
1answer
63 views

Changing the spacing between files in ls

This is more of a cosmetic question but this is really bugging me. On OS X, when I run ls -G (or use CLICOLOR=1) instead of regular ls it changes the spacing of the columns, as you can see in this ...
3
votes
5answers
126 views

List files with line count and date

I want to be able to list files showing the number of lines the each file has and the date. I can happily get the line count using wc -l *. Not a problem. I can get the date using ls -l. Is there a ...
3
votes
1answer
337 views

It's bad to use ls -A to list hidden files?

I want to list every file, including hidden files, in the current directory. I don't want to include the parent (..) and current (.) directory. I found this: how to glob every hidden file except ...
3
votes
3answers
113 views

Sorting directories by last modified date/time of the same-named contained file

Is it possible, using grep, find, etc, to sort a list of directories by the last modified date of the same-named file (e.g., file.php) within? For example: domain1/file.php (last modified 20-Jan-2014 ...
0
votes
1answer
43 views

Executable directory? And chmod o+w changing the terminal directory color?

What does an executable directory mean? If o+w is set the directory changes colors to a background green, what does this mean? Why doesn't it do it for ug+w, but only for o+w? Additional question ...
0
votes
2answers
132 views

proper way to iterate through contents in a directory [duplicate]

I need to iterate through every file inside a directory. One common way I saw was using the for loop that begins with for file in *; do. However, I realized that it does not include hidden files ...
-1
votes
2answers
49 views

Matching multiple patterns with ls

I'd like to get a list of fail logs in the current directory for use in an outside script, the logs are determined with the pattern FAIL in the filename, so I've been using a FAIL* to feed my script ...
1
vote
2answers
161 views

sort and ls — why aren't capitalized letters sorted first?

I want a sorting like this, with capitalized letters before lowercase: -rw-r--r--. 1 0 0 183 2014-10-14 20:17 ./CHECKSUMS.md5 -rw-r--r--. 1 0 0 185 2014-10-14 20:17 ./CHECKSUMS.asc ...
0
votes
2answers
67 views

ls hard link question

I run ls -la on the Volumes directory. It shows the MM dir to have 9 hard links and the Media dir to have 12. If I then cd to the MM directory and run ls -la, it shows only 7 items whereas if I cd to ...
1
vote
2answers
34 views

Listing folder contents during cd command

I might be mistaken here, but I was watching someone navigate using the cd command, and without actually executing it, they were able to show the folder contents of the current folder. So if I type ...
6
votes
1answer
86 views

???? files in ls -l output

I see ghost files in red colour inside some of my directories: [drey@cyan|23:54|~/downloads]ls -la ls: cannot access teamviewer9_linux.deb: No such file or directory total 1318096 drwxrwx--- 1 root ...
2
votes
2answers
220 views

Change file timestamp and display hour instead of year with ls

I want to change a file's date to tomorrow 21:00. I used touch, but when I type ls -l the year of the file is displayed instead of the hour. -rw-r--r-- 1 ABCD DEF 0 sept. 30 2014 test01 -r-xr-xr-x ...
15
votes
4answers
2k views

Why does “ls | wc -l” show the correct number of files in current directory?

Trying to count number of files in current directory, I found ls -1 | wc -l, which means: send the list of files (where every filename is printed in a new line) to the input of wc, where -l will count ...
0
votes
1answer
96 views

External Hard Drive Issue on mac

After the cd /Volumes command when I type ls it shows me my hard drive name twice, with different permissions. After that when I try to use mkdir to create a directory in the external hard drive I'm ...
5
votes
1answer
121 views

How to colourise hidden files in `ls` file listings?

LS_COLORS environmental variable lets you decide on colours for different file types for ls command, such as, directories, regular files, links etc. I suppose that dot files are considered a variation ...
3
votes
1answer
231 views

Putting Files in Ascending order (not on time stamp basis) in Unix [closed]

How do I list files in Ascending manner, not on time stamp basis. EX:- Original listing A_2001 A_2002 A_2003 A_2004 B_2001 B_2002 B_2003 B_2004 Desired output:- A_2001 B_2001 A_2002 B_2002 ...
0
votes
1answer
57 views

Difference between “ls -l” and “dir -l” [duplicate]

What is the difference between ls -l and dir -l? I always use ls -l, but my colleague (who is slightly colour blind) uses dir -l. Is this the only difference: ls -l has colour and dir -l not have ...
0
votes
1answer
105 views

Delete empty directories using 'ls' command

I want to delete empty directories without using find command find . -empty -type d -delete. like the following: if [ "$(ls -d *)" ]; then echo "Not Empty" else echo "Delete" fi How do I ...
-2
votes
1answer
130 views

Find files using ls and wildcards

pwd : ../bin under bin I have a directory called datafiles. Use meta characters and the ls -lL command (with lower and upper case L) to list all filenames under the datafiles directory that contain a ...
31
votes
1answer
3k views

Why can Linux show a file name containing character '/'?

The following picture is snapped in a real Linux environment. Why can Linux show a file name containing character '/'?
1
vote
1answer
65 views

ls and find command excluding a certain directory

I want to do this: ls -altrhS 'find / -type d \( ! -name tmp -prune \) -size +10000k 2> /dev/null -print' | egrep -v 'ibd|MYD|MYI' So I want to list, in that format, files of a specific size ...
0
votes
1answer
113 views

Linux can't read and write, but windows can

I have a hard drive with a lot of back up files, that were created by PhotoRec. When mounting it with a windows computer I can read all the files perfectly fine. Under linux I get an error when ...
1
vote
2answers
43 views

How do I find a files directory?

I am looking for a specific file in OS/X. I can see the file by using: ls -alR | grep "mkmf.*" This shows my that the file exists. How do I find what directory the file is located. Many thanks ...
2
votes
1answer
29 views

Regarding identical copies of gedit files

When ever I save a gedit file in a directory, two copies of it get saved with identical content. Ex: If the gedit file is named as file_name and saved in Home directory then when u ls the Home ...
3
votes
2answers
103 views

exit a script if an ls line did not find any match

I am writing this script that have this line: ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable What I wanted is to exit the script (without using if-statement) if it ...
5
votes
3answers
811 views

Sorting ls output by time, when there are too many files for a single invocation

I know that I can sort the output of ls by time with the -t option. I know that when I have so many files that they don't fit in a single ls invocation, I can normally use xargs (or find ... -exec ...
12
votes
4answers
689 views

Why does ls accept duplicate switches?

I'm curious - is there a difference between ls -l and ls -lllllllllllllllllllllllllllll? The output appears to be the same and I'm confused on why ls allows duplicate switches. Is this a standard ...
1
vote
3answers
429 views

Why is ls command slow to interrupt on NFS directory with lots of files?

I noticed in directories with lots of files on NFS if I do ls * then hit Ctrl-C it can take a while ( say 20 seconds ) before ls comes back. Why? Can ls command be fixed to be more responsive?
0
votes
1answer
393 views

ls command - list files containg speccific string in file name and belong to specific type

I am new to linux. Is it possible for a ls command to return a list of files containing "PRO" in its file name and belong to pli file type. I have researched and identified that ls -c -lt *.PLI will ...