Tagged Questions
6
votes
1answer
53 views
How to do `head` and `tail` on null-delimited input in bash?
find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that ...
0
votes
2answers
155 views
How to find and replace a particular string in a specific line
I developed a code which find and replaces a specific string in all xmls under all subdirectories. But i dont want all occurances to be replaced. In entire xml, code should find the tag xyz and ...
1
vote
2answers
223 views
Command to find file/path lengths that are too long for burning to DVD?
I'm trying to burn a DVD from Windows but it fails because the full path name length exceeds the limit of something like 255 characters.
Our files are stored in Debian Linux (accessed by Windows ...
2
votes
2answers
99 views
How can I enhance the output of find and grep?
I really don't look forward to having to do find/grep because the output, as returned by
find . -exec grep sometext {} \; -print
is just not very easy to read even when you dump it in a file. What ...
2
votes
3answers
2k 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
639 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
2k 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
363 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 ...
6
votes
4answers
3k 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 ...
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
...
16
votes
7answers
20k 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 ...
3
votes
1answer
1k 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 ...
