The ls command lists the contents of a directory.
7
votes
3answers
930 views
Why is sorting files by access time not working?
I tried to use command
ls --time=atime
it was working in one directory but wasn't working in another directory.
I opened certain files in vim, evince and other applications but after the
command file ...
20
votes
6answers
3k views
what does the @ mean in ls -l?
I am using Mac OSX. When I type ls -l I see something like
drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 .
drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 ..
-rwxrwxrwx@ 1 xonic staff 6148 25 ...
3
votes
1answer
2k 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?
2
votes
2answers
2k views
Want to sort files by update date including sub-directiroies
I want to sort only files by update dates including sub-directories.
I found out ls -lrtR |grep ^-. but it doesn't seem to sort by update dates.
And I need to save this list into a file. Is it ...
3
votes
2answers
1k views
file block size - difference between stat and ls
I've noticed that when I do a:
ls -ls file
It provides block count, say 8 blocks.
When I do:
stat file
I notice that the block count is 16, twice the number given by ls.
The block size on my ...
8
votes
3answers
1k views
How can I use ms-dos style wildcards with ls and mv?
I have the misfortune of coming from a MS-DOS background - but at least it makes me appreciate how much more powerful Linux is. I've been working on getting my Linux-Fu up to par, but there are a ...
3
votes
2answers
463 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 ...
3
votes
2answers
122 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 ...
7
votes
6answers
4k views
What's the best way to count the number of files in a directory?
If parsing the output of ls is dangerous because it can break on some funky characters (spaces, \n, ... ), what's the best way to know the number of files in a directory?
I usualy rely on find to ...
3
votes
1answer
243 views
Zsh autocomplete ls command with directories only
Suppose I have following files and directories:
% ls
bui00293 buiawer builds/ buiowpe/
I want to list the content of ...
-2
votes
1answer
199 views
Why does this script show all files in the directory and not just PDF files?
I wrote the script below to find the number of PDF files in a given directory. However, it instead shows all the files in the directory:
#!bin/bash
message="."
message1="*.pdf"
ls -al $message ...
3
votes
2answers
92 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 ...
6
votes
1answer
316 views
Controlling what files to display
I recently changed my emacs config to hide backup files by prepending a dot to the file name. This got me to thinking - is there a ready way to change the behavior within Bash to use a list of ...
1
vote
1answer
168 views
file missing from Desktop screen but can be seen using “ls” under the Desktop directory
I downloaded some files onto desktop. After typing ls under the Desktop directory, I can see these files. However, I cannot see the icons on my desktop corresponding to the files I see with ls. I use ...
1
vote
1answer
228 views
colorizing ls output based on filename
i'm on freeBSD and trying to colorize ls output, so i've added
alias ls ls -lhG
setenv LSCOLORS gxfxcxdxbxegedabagacad
to my .cshrc
and it works. but what i really want to - is to be able ...
2
votes
3answers
258 views
How universal is the -L (dereference symlink) switch of the 'ls' command?
I have some software that, among other things, needs to:
Assess a file's rwxrwxrwx permissions;
Work under every possible flavor of Unix and Linux you can find in the wild.
Currently, it does that ...
-1
votes
1answer
181 views
How can I tell when a file was modified?
I am running some simulation on a high performance computing cluster (HPC). When I check when the file was changed with ls -t I get the wrong result. I know this becouse I have run a small job that ...
5
votes
4answers
3k views
How to find a file in the filesystem from the command line?
I'm fairly new to Linux, and I've now found myself in a situation where I'd like to find where a file (with a partially-known filename) is in the file system. I'd like to know how to do this from the ...
7
votes
2answers
1k views
Testing LS_COLORS in zsh
A few years ago I found an interesting code snippet that prints each type of file in its corresponding color according to the colors set up in LS_COLORS. Unfortunately, I can't remember the link ...
13
votes
3answers
336 views
When does `ls -s` print “0”
Of course, the standard way of testing if a file is empty is with test -s FILE, but one of our clients have received a script containing tests like this:
RETVAL=`ls -s ./log/cr_trig.log | awk '{print ...
2
votes
2answers
344 views
How do I show all files in a directory except those that have a certain extension AND display them in multiple columns?
Since I write in Python a lot it's kind of annoying to see .pyc files all the time and I would like to just hide them at this point. I tried the following, but I can't seem to figure out how to get it ...
4
votes
4answers
789 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.
...
0
votes
3answers
3k views
How to copy files from linux to windows using winscp from a folder which contains millions of files
I need to copy files from a linux machine to a windows machine where the only ports which can be open are for SSH (22).
I can connect to the linux machine using WinSCP but the problem is once I try to ...
4
votes
4answers
363 views
ls command operating differently depending on recipient
How does commands like ls know what its stdout is?
It seems ls is operating different depending on what the target stdout is. For example if I do:
ls /home/matt/tmp
the result is:
a.txt b.txt ...
4
votes
4answers
3k 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 . ...
3
votes
2answers
603 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
...
1
vote
1answer
475 views
Difference in file listing for SSH and SFTP [closed]
I have SSH access to a server and I have never bothered to use SFTP until now.
I transferred a file using FileZilla to the server. However, the weird thing is that the file doesn't show up when I ...
1
vote
3answers
519 views
Ls with spaces + variables
I want to do something like this, but it doesn't save the variable after the piping ends:
fs=( )
echo ${fs[@]}
ls -A1 |
while read f
do
echo ${fs[@]}
fs+=( "$f" )
echo ${fs[@]}
done
echo ...
5
votes
5answers
3k views
List files larger than {size} sorted by date
I want to solve the problem 'list the top 10 most recent files in the current directory over 20MB'.
With ls I can do:
ls -Shal |head
to get top 10 largest files, and:
ls -halt |head
to get top ...
2
votes
3answers
944 views
Really strange FAT32 file listing problem
I'm mounting a FAT32 drive on my NAS (which has a USB port), and hitting a strange issue when I use the ls command on the drive root:
ls: cannot access ???²é?u.g: Input/output error
ls: cannot ...
0
votes
2answers
2k views
Human-readable ls output under AIX?
How can I get human-readable ls output under AIX? There is no -h parameter
2
votes
1answer
781 views
Enable line breaks when assigning multi line outputs to var in bash
I'm using the following very basic shell script I copied off the net to list the contents of my database backup folder and mail them regularily:
MYSQLLIST=$(ls -lhG /var/backups/mysql/daily/)
...
1
vote
1answer
329 views
How can I make ls show information about the directory specified only, not info about its sub-files or folder contents?
Say I have folder "foo" residing, the home directory. I want to get some info of it, owner, group, permissions, etc...
I then do this to try to get the information:
cd ~
ls -l foo
Of course it now ...
4
votes
2answers
397 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
1k 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 */ ...
6
votes
1answer
377 views
Using dircolors, how do I change the color of my subversion folders
Below is a sample of my dircolors file, I want subversion folders (.svn) to be colored, but i guess the extension section only applies to file names.
How do i set colors for directories with ...
2
votes
2answers
161 views
Move one file at a time based from specific number in the files
Based from this question, The HTML files date format has been changed. All of the HTML files have the date such like below:
20110730dateishere
dateishere is intentionally added by me in the files, ...
6
votes
1answer
7k views
Bash: assign ls | grep to a variable and echo it with a string
I want to assign the result of an expression to a variable and concatenate it with a string, then echo it. Here's what I've got:
#!/bin/bash
cd ~/Desktop;
thefile= ls -t -U | grep -m 1 "Screen Shot";
...
2
votes
1answer
1k views
Why can't list file/directory relative to .. from a symbolic link directory (No such file or directory)?
I have a /usr/tomcat6/logs directory linked to /var/log/tomcat6.
When I changed directory to /usr/tomcat6/logs and try to ls files using a relative pathname ../conf/Catalina/localhost, a No such file ...
4
votes
1answer
900 views
ls: how do I list directories sorted by timestamps of the files it contains
How do I list directories by their access time in the sense that some new files/directories are created (say, directories containing the most recently created files).
3
votes
1answer
742 views
ls -a not showing folder “system”, but echo * shows it
When I create a folder named system in my home folder, or in /tmp (can't try other locations as I am not root, but owner confirmed same problem even on root), ls -a will not show it. Also tried ...
5
votes
4answers
999 views
What is the “directory order” of files in a directory (used by `ls -U`)?
According to the man page for ls, ls -U means:
do not sort; list entries in directory order.
What does "directory order" mean, and how is it determined?
The following test (executed on an ...
6
votes
3answers
1k views
How do i open all files that are the result of a ls command?
I'd like to open all text files that are the result of a ls command using a text editor. How do i do this?
24
votes
1answer
1k views
Why does “ls *” take so much longer than “ls”?
I have a couple of files in a directory:
$ ls | wc -l
9376
Can anybody explain why there is such a huge time difference in using ls * and ls?
$ time ls > /dev/null
real 0m0.118s
user ...
3
votes
2answers
375 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 ...
9
votes
1answer
30k views
How to get only files created after a date with ls?
With ls command, does it possible to show only file created after a date, hour...
I'm asking it because I have a directory with thousand of files.
I want files created since yesterday.
I use ls ...
9
votes
3answers
5k views
Find the owner of a directory or file, but only return that and nothing else
I am looking for a command that will return the owner of a directory and only that--such as a regex parsing the ls -lat command or something similar? I want to use the result in another script.
3
votes
1answer
175 views
ls pagination on MontaVista with BusyBox
I'm logged into an IP Phone running MontaVista with a very stripped down BusyBox binary (by stripped down, I mean the OEM has removed almost all of its functionality, except the basics like cat, ls ...
9
votes
3answers
5k views
What is the Linux equivalent of DOS “dir /s /b filename”?
List all files/dirs in or below the current directory that match 'filename'.
4
votes
2answers
1k views
Scrolling through ls output without a mouse
In some directories there are quite a few files. When I use ls the output is more than my terminal can handle. Typically I just use one of the following:
ls | less
ls | more
depending on my mood. ...