Tagged Questions
1
vote
2answers
226 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 ...
6
votes
3answers
288 views
Is it possible to nest a 'find -exec' within another 'find -exec'?
Something like the following is what I what I'm after,
but my code doesn't work, no matter how I escape {} and + ;
find ./ -maxdepth 1 -type d -name '.*' -exec \
find {} -maxdepth 1 -type f ...
2
votes
4answers
480 views
Deleting Lines Containing a Specified String in Different Files
Suppose there are two files in web/ named foo.php and bar.php. The 1st line of foo.php is "sdajgeSTRINGdsad" and the 10th line of bar.php is "gdfhu98324STRING". The task is to first locate these two ...
2
votes
2answers
179 views
Remove slashes/parent paths from filenames inside CSS and Javascript content
I need to go through all my css and js files and if there is a filename referenced that has any slashes (/) at all then the slash should be removed.
What I want is:
if any files referenced are ...
3
votes
3answers
1k views
How do I recursively grep through compressed archives?
I'm trying to find out what modules use Test::Version in cpan. So I've used minicpan to mirror it. My problem is that I need to iterate through the archives that are downloaded, and grep the files ...
11
votes
6answers
6k views
Looping through files with spaces in the names?
I wrote the following script to diff the outputs of two directores with all the same files in them as such:
#!/bin/bash
for file in `find . -name "*.csv"`
do
echo "file = $file";
diff ...
2
votes
3answers
831 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
...
2
votes
1answer
408 views
Remove files, which provided by pipe
I have this command chain:
find . -print | grep php | xargs grep 'eval' -sl | xargs wc -l | grep ' [1-2][0-9] '
This provide me this output:
14 ./includes/js/calendar/lang/vgju.php
18 ...