3
votes
6answers
128 views

ls content of a directory ignoring symlinks

I have a directory in which I would like to list all the content (files and sub directories) without showing the symbolic links. I am using GNU utilities on Linux. The ls version is 8.13. Example: ...
-1
votes
4answers
82 views

How to exclude directories from `ls -R` output?

If ls -aR | grep ":$" returns ./.hiddendir2: ./dir1: ./dir3: ./dir3/.hiddendir4: then how can you update the pattern given to grep so that you only get ./dir1: ./dir3: (note that the last ...
3
votes
5answers
578 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 ...
2
votes
3answers
338 views

Command substitution in for loop not working

I want to keep all files not ending with .bat I tried for f in $(ls | egrep -v .bat); do echo $f; done and for f in $(eval ls | egrep -v .bat); do echo $f; done But both approaches yield the ...
1
vote
1answer
489 views

What is a sure fire way to find all files and/or path that contains 2 keywords?

I was doing a find . -iname '*sitesearch*' | grep demo because I know the file should be some/path/SiteSearch/demo/SiteSearch.html, but it turned out a person put the file in as ...
3
votes
5answers
384 views

Print non-existent files from a pipe input

I have a directory of lots of .PDF and .JPG files. There should be a .JPG file for each .PDF with the same name. I'm trying to use a command to find .PDF files that doesn't have a .JPG file. My ...
4
votes
2answers
554 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
901 views

How do regular expressions differ from wildcards used to filter files

While we use * to denote zero or more previous characters in grep, we use *.c to find all C files when we use it with the ls command like ls *.c. Could someone tell how the use of * differs in these ...
11
votes
6answers
7k views

How do I list every file in a directory except those with specified extensions?

Suppose that I have a folder containing .txt, .pdf, and other files. I would like to list the "other" files (i.e., files not having the extensions .txt or .pdf). Do you have any advice on how to do ...
0
votes
2answers
492 views

ls outputs multiple columns even if piped to grep with grml's zsh config

I just decided to give zsh a go against Bash and came across some unhandy behaviour about which I couldn't find anything on the net: If you do a ls | grep foo in Bash, the ls only contains one file ...
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 ...
2
votes
2answers
865 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 ...
9
votes
1answer
15k views

How can I assign the result of a command to a shell variable?

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"; ...