Tagged Questions
3
votes
2answers
58 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 ...
0
votes
3answers
55 views
How to find files ending with ~ and pyc? [duplicate]
I want to find all files (in current and all subdirectory) which end in'~' or 'pyc'. To do so I have tried the following find pattern:
find . -name '*{~,pyc}'
find . -name '{*~,*.pyc}'
but neither ...
1
vote
3answers
167 views
What does a question mark in a filename matching pattern mean?
What does the question mark in this command mean?
find . –type d –name "?d*" –print
I tried to to run it without it but didn't notice any change.
2
votes
2answers
62 views
Select greatest numbered filename
Simple requirement but can't find anything online which can achieve it.
I have a list of dated files as below...
filename_20120101.dat
filename_20120102.dat
filename_20120103.dat
I ...
6
votes
2answers
148 views
Remove all Vim undo files in all but one directory
I just realized that I have tons of Vim undo (.un~) files sprinkled around my file system. I'd like to delete all of these files except in one directory—~/.tmp. My first problem is that I can't seem ...
2
votes
2answers
91 views
What is an equivalent of rm `find lib/ -name *.swp` without find?
As in the title, I would like to remove all files in the lib directory with .swp in the end.
How can I do this without find in:
rm `find lib/ -name *.swp`
18
votes
1answer
652 views
Why doesn't 'find' show this file?
Using find with grep, one can locate files that match a pattern:
# find | grep error
./solr-modifiedSolr4/SolrPhpClient/phpdocs/errors.html
./error_log
./includes/classes/error_log
However, using ...
4
votes
2answers
171 views
Why 2 linux machine behave differently with command of the same syntax?
I am using 2 machine , which is both Red Hat Enterprise Linux AS release 3 (Taroon Update 2)
( I check it in /etc/*-release ).
I checked they are using the same default shell by ps -p $$, which is ...
4
votes
3answers
338 views
Delete matching file from every subfolder of current dir
I used this one to copy file in every dir:
find -type d -maxdepth 1 -print0 | xargs -0 -n1 cp .htaccess
Now i need to do reverse one and delete file with matching name from every sub directory of ...
3
votes
1answer
193 views
Copy files in different subdirectories that excludes a string
I'm trying to copy all files of a type in a given directory and subdirectories but excluding files of a different type.
find /var/ftp/pub/bs -iname "*foo*.foo" -exec cp {} /var/ftp/pub/bs1 \;
...
4
votes
4answers
297 views
Find files without a number
I am trying to write a simple script that will iterate through all drives except sda. Right now I have this
for i in $(find /dev/ -name "sd*" ! -name "sda*")
do
echo $i
done
However this ...
0
votes
0answers
105 views
How to use find command with wildcard when current directory contains a match? [duplicate]
Possible Duplicate:
find not recursive when file at top
I'm having some confusion with the find command.
If I type:
find . -name *.xml
or
find ./ -name *.xml
I receive a list of all ...
5
votes
5answers
2k views
How to copy all html files from a directory tree to a single directory?
I want to copy all the .html files in myDir and its subdirectories to ~/otherDir. Here's what I tried (it doesn't work):
$ find myDir -name *.html -print | xargs -0 cp ~/otherDir
usage: cp [-R [-H | ...
2
votes
3answers
2k views
How can I loop through lines of a file and find files matching each line?
In a BASH shell, I would like to take the lines of a file (eg pattern.txt) and find the files on my system whose names contain the patterns in each line of my file. So, I have the following for loop
...