Tagged Questions
21
votes
7answers
2k views
why does ls -d also list files, and where is it documented?
when specifying ls --directory a* it should list only directories starting with a*
BUT it lists files AND directories starting with a
Questions:
where might I find some documentation on this, ...
2
votes
2answers
85 views
Working of rm/ls with [0-9]
I am learning the shell commands and came across the short tags eg.[0-9],[[:digit:]] etc.. As a proof of concept i tried deleting all the files with the rm command(i know its not a good practise but i ...
2
votes
4answers
99 views
Find directories that do not contain subdirectories
I'm writing script is ksh. Need to find all directory names directly under the current directory which contain only files, not subdirectories.
I know that I could use ls -alR and recursively parse ...
5
votes
4answers
329 views
Shell command to get all the files from a complex directory structure
I'm looking for a shell command in order to get all the files in a complex directory structure. By complex directory structure I mean that there's a root folder with more than 150 subfolders and for ...
1
vote
2answers
158 views
Ignore all matches to negated extglob pattern in recursive ls
I would like to recursively list all files in a directory which match a given input pattern using ls. (Oh, and this is in Bash).
The only way I can think of to do this using ls is to shopt -s extglob ...
3
votes
2answers
184 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 ...
2
votes
1answer
224 views
How does wc -l `ls` give the actual number of lines?
Can anyone explain to me how does this command work.
wc -l `ls`
while this command gives the total number of java lines or txt lines.
0
votes
1answer
161 views
difficalty to save traceroute output in shell variable?
I need to filter and store traceroute output in shell variable (array). But I am getting some unusual output.
As I try to explain in following lines.
My present directory is temp, having some ...
1
vote
2answers
170 views
Displaying the last N modified files?
How can I list the 10 most recently modified files of a certain extension, not all files, or the files modified during the last 2 days for example?
4
votes
4answers
198 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
...
1
vote
2answers
230 views
List info about files/directories with spaces
I am trying to use ls to get information about files and directories. My current command fails to properly get the name whenever a file/directory has a space.
I am using this to list all ...
3
votes
3answers
341 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 ...
1
vote
5answers
905 views
ls: Do not show directories that match same pattern in wildcard searches, only files
Supposing I have something like the following, a typical business PC situation:
drwxr-xr-x 1 whatever whoever 3 Oct 3 16:40 invoices2009
drwxr-xr-x 1 whatever whoever 4 Oct 3 16:40 ...
12
votes
5answers
3k views
How to match case insensitive patterns with ls?
I would like to list all files matching a certain pattern while ignoring the case.
For example, I run the following commands:
ls *abc*
I need to see all the file that have "abc" as a part of the ...
1
vote
1answer
275 views
M-x ansi-term colors in Emacs 24.x
I have noticed that some colors in LS_COLORS don't work when running a shell inside M-x-ansi-term in Emacs.
For exmaple;
di 00 94
is supposed to turn on bold on light blue on directories on ...
5
votes
4answers
332 views
ls colors for permissions
Is there a way to control the color output of ls to highlight specific permissions on files? (e.g. write permissions).
Any options in LS_COLORS that would do this? (the image above is from Dired+ ...
1
vote
3answers
2k views
List only regular files (but not directories) in current directory
I can use ls -ld */ to list all the directory entries in the current directory. Is there a similarly easy way to just list all the regular files in the current directory? I know I can use find
find . ...
4
votes
3answers
253 views
How can I do the equivalent of tail -f with ls? [duplicate]
Possible Duplicate:
Is it possible to follow a command (run repeatedly)? as one would follow a file using tail -f?
I would like to monitor files that are being downloaded to a directory in ...
1
vote
3answers
196 views
Display a menu of files names and let the user select a file by entering a number
I have created a script that allows the user to select a file by copying and pasting that file. Then perform a grep on that file. I want to know is it possible to put a number in front of each files ...
12
votes
1answer
2k views
ls taking long time in small directory
Running Ubuntu, I open a terminal and do
sudo bash
cd /
ls | head -n 1000
And predictably about 20 directories are returned.
However, if I do an ls, and don't pipe it into anything, the ls just ...
3
votes
2answers
121 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
2answers
90 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
2answers
576 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
...
2
votes
1answer
743 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/)
...
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 */ ...
4
votes
4answers
761 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.
...
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?
14
votes
9answers
2k views
Linux - command to list files (except ls)
Imagine you were working on a system
and someone accidentally deleted the
ls command (/bin/ls). How could
you get a list of the files in the
current directory? Try it.
I tried many ...
4
votes
2answers
5k views
Why is Debian's root shell colorless?
Are there any security concerns? What is the best way to enable it?
4
votes
2answers
486 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
1answer
257 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 ...
13
votes
2answers
1k views
ls command: what does the first line mean?
I haven't been able to find this through internet, when I make ls -l I get this:
calico@A000505:~/Documentos$ ls -l
total 2020
-rwxr-xr-x 1 calico calico 8559 2010-11-16 11:12 a.out
-rwxrw-rw- 1 ...
6
votes
1answer
283 views
How do I get a long listing for a single directory?
I want to see a long listing for a single directory. When I type ls -lha, I see this:
drwxrwxr-x 4 username groupname 4.0K 2010-08-05 09:55 files
drwxrwxr-x 7 username groupname 4.0K 2010-08-05 ...

