1
vote
2answers
30 views

Getting the size of parent folders when using find to search for criteria?

I am hunting for a certain regular expression within the filenames and am seeking to return the parent folders with their sizes in a unique fashion. For example, here is the command that I expected ...
4
votes
3answers
119 views

zsh's “echo SomeText >> **/filename” in other shells

I need to fill all files with a specific filename (recursively) with a text. In zsh this can be done with echo SomeText > **/TheFileName I search generic solutions for sh-compatible and/or tcsh ...
4
votes
1answer
128 views

Blank lines when executing “grep | xargs” in a “find -exec”

I'm trying to list all directories of a web server that are blocked by Apache via a .htaccess (containing deny from all). I've managed to get the list of blocking .htaccess but when I try to extract ...
1
vote
2answers
148 views

Output of command when piped to another command

I am running a command which does a quick checksum of some file like so find / -type f -ctime +30 -mtime +30 -atime +30 -exec md5sum {} \; | xargs -P 4 and I am trying to run it in parallel with ...
2
votes
2answers
148 views

Understanding -regex with GNU find

Background I have what I think should be a simple case. I want to find all files with "cisco" in the name and do something with those files (via xargs). Finding files with ls Before I use xargs, ...
2
votes
2answers
183 views

Use xargs to move files from within a directory

I am searching for some folders in my current directory. What I want to do is, move all the files within those directories to another directory. I am using the following command: find -maxdepth 1 ...
2
votes
4answers
453 views

Zgrep stop after first match when arguments are passed from xargs

I'm using this command to find patterns in zip files (similar to the one) suggested here http://superuser.com/questions/144926/unix-grep-for-a-string-within-all-gzip-files-in-all-subdirectories find ...
0
votes
2answers
2k views

How can I find files and then use xargs to move them?

I want to find some files and then move them. I can find the file with: $ find /tmp/ -ctime -1 -name x* I tried to move them to my ~/play directory with: $ find /tmp/ -ctime -1 -name x* | xargs ...
4
votes
1answer
3k views

Moving files with find + xargs: target is not a directory?

When I run the following command: > mkdir some_dir > find /foo/bar/ -name '*.csv' -print0 | xargs -0 mv {} some_dir I get hundreds of lines that say: mv: target `/foo/bar/XX.csv` is not a ...
1
vote
1answer
53 views

Change some ASP code to PHP code in all files

I'm migrating a directory of files containing fairly simple ASP code over to a PHP server and I need to modify the contents of all the files with a find and replace mechanism. I'm not great with ...
3
votes
3answers
545 views

Concatenating thousands of files: > vs >>

I found two seemingly contradictory answers on StackOverflow to the following questions: Concatenating Thousands of Text Files Across Hundreds of Directories (while keeping some structure) How do I ...
11
votes
1answer
333 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 ...
1
vote
3answers
1k views

find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664; does not work

I am using this command to set permissions for files recursively clime@vm6879 /srv/www-php/steeltrading $ find . .[^.]* -type f -print0 | xargs -0 sudo chmod 664 But after executing that command ...
1
vote
1answer
168 views

Wrong behavior of xargs

I was trying to solve this issue using find + xargs but I stuck with another issue I am try to increasing a count using ((a++)) but not working . I have tried couple of combination of counting a ...
2
votes
3answers
1k views

`solaris + xargs command for solaris

the command find /tmp -name 'core*' -type f -print0 | xargs -0 works fine on Linux, but xargs -0 option is not legal on Solaris what is the equivalent option ( xargs? ) for Solaris 10 second ...
2
votes
3answers
249 views

How to copy a list of files and adjust destination filenames on the fly?

When I don't need to adjust destination filenames I can do something like this: $ find -type f -name '*.pat' -print0 | xargs -O cp -t /path/to/dest It is safe because the filenames may even ...
2
votes
3answers
577 views

Howto recursively create PDF thumnbails on linux command line

I am able to use ImageMagick to create a thumbnail of the first page of a PDF using: convert -thumbnail x80 95.pdf[0] thumb_95.png This works fine and generates a thumb_95.png file. I have tried ...
1
vote
1answer
365 views

Speeding a find rm command with test through parallelization

I want to recursively delete all files in directories and subdirectories with number of lines less than 10, and am currently using the following command find . -type f -name "*.txt" | while read; do ...
6
votes
5answers
1k views

Find images by size: find / file / awk

I've been trying to find png image files a certain height (over 500px). I know that file will return image dimensions. Example: $ file TestImg1a.png TestImg1a.png: PNG image data, 764 x 200, ...
1
vote
3answers
2k views

Linux: Does find | xargs grep have limitations?

I've historically performed something like: find . 2>/dev/null | xargs grep -i something_to_find 2>/dev/null If my pwd is barfoo (/foo/bar/baz/foofoo/foobar/foobaz/barfoo) it finds matches. ...
5
votes
2answers
1k views

Reformatting a large number of XML files

I'm manipulating a large number of XML files scattered throughout a nested directory structure. I tried the following (which almost works): $ find . -name "*.xml" -type f | xargs -- xmllint --format ...
11
votes
3answers
5k views

Find -exec + vs find | xargs. Which one to choose?

I understand that the -exec can take a + option to mimic the behaviour of xargs. Is there any situation where you'd prefer one form over the other? I personally tend to prefer the first form, if ...
4
votes
4answers
2k views

Remove numbers from filenames

I've a problem modifying the files' names in my Music/ directory. I have a list of names like these: $ ls 01 American Idiot.mp3 01 Articolo 31 - Domani Smetto.mp3 01 Bohemian rapsody.mp3 01 Eye of ...
4
votes
2answers
569 views

Append line to many files

I want to add some text to over 200,000 files I am trying this find . -name *.txt -print | xargs -I % echo "hello world" >> % But nothing is happening. When i run find . -name *.txt it work ...
2
votes
3answers
4k views

How to delete files filtered out by awk

I have the following files in a directory: -rw-r--r-- 1 smsc sys 46 Apr 22 12:09 bills.50.1.3G.MO.X.20120422120453.Z -rw-r--r-- 1 smsc sys 28 Apr 22 12:15 bills.50.1.3G.MO.X.20120422120953.Z ...
3
votes
3answers
5k views

How can I pass strings with single quotes to grep?

My desired outcome is the following: to recursively search a directory looking for a given string in all found files. The following command is my usual port of call: find ./ | xargs grep -ns 'foobar' ...
11
votes
4answers
11k views

Sorting the output of “find”?

I need to be able to alphabetically sort the output of find before piping it to a command. Entering | sort | between didn't work, so what could I do? find folder1 folder2 -name "*.txt" -print0 | ...
4
votes
6answers
1k views

Grep a directory and return list with line numbers

I'm currently trying to learn more about bash scripting and all of that fun stuff, and I pieced together this little command: find $path | xargs grep -n $pattern | awk '{print $1}' While this DOES ...
2
votes
3answers
2k views

create md5 hash from a recursive file listing when some paths have spaces

I need to create an md5 hash of every directory and file inside of one main directory. The only thing that is keeping me from success is figuring out a way around files with a space in the path. I am ...
6
votes
6answers
14k views

How to search for a word in entire content of a directory in linux

need to search for something in entire content I am trying: find . | xargs grep word I get error: xargs: unterminated quote How to achieve this?
3
votes
4answers
2k views

rename character “â” of directory name?

I'm trying to rename rename character â of directory name to be blank. For example, directory with name how-â8093-to. This is the command I use, including some other modification find . -type d | ...
3
votes
3answers
198 views

Use find to execute series of commands

I want to examine a directory and execute a command for each matching folder. The following find correctly returns the list I'm looking for. find . -maxdepth 1 -name "*.bitbucket" For each item ...
14
votes
2answers
905 views

gnu find and masking the {} for some shells - which?

The man page for gnu find states: -exec command ; [...] The string `{}' is replaced by the current file name being processed everywhere it occurs in the arguments to the command, ...
4
votes
3answers
4k views

Pass xargs argument as a string to another command with '>'?

Suppose I have a bunch of files in /tmp/. I do find . -type f | xargs -iFILES And I want to do a md5sum in each file, outputting to a file with the same name, but with .md5 extension. find . ...
3
votes
1answer
3k 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 ...
7
votes
3answers
3k views

How to open multiple files from `find` output?

I know I can open multiple files found in a dir like so: find -name *.foo -xargs <command> {} \; This works, but when trying to open a bunch of textfiles in gedit at the same time, it opens ...
5
votes
4answers
997 views

recursively chmod

I was trying to chmod folders and files with: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; But I was wondering: How to do it in one line using find and excluding the ...
11
votes
3answers
2k views

bash find xargs grep only single occurence

Maybe it's a bit strange - and maybe there are other tools to do this but, well.. I am using the following classic bash command to find all files which contain some string: find . -type f | xargs ...