0
votes
2answers
43 views

Why doesn't xargs on find work with a series of commands using pushd and popd to walk a directory subtree?

On a Linux Centos 4 machine, I am trying to create a simple bash command line to walk a directory structure below an arbitrary current directory and in each subdirectory touch a file, list the ...
0
votes
1answer
87 views

Find & du to calculate total size vs xargs

Can someone confirm that the following one liner will produce the total human readable size of all the directories which FIND locates as having log in the name? find -type d -name *log* | du -hcs
0
votes
0answers
36 views

I'm trying to list size of folders plus selected files on a portable disk

For the purpose of finding the location of my data among many portable disks, I'm trying to create plaintext lists of the contents of all folders and files of certain extensions and sort them by size. ...
1
vote
2answers
32 views

Find two newest change files and compare them

I have a script that wgets a .txt file and datifies the names. I'd like to diff the changes between the newest & next-to-newest file. This is how I am able to select them: ls -t -l | awk ...
1
vote
2answers
234 views

batch find/replace using sed or awk

In every file with filename matching pattern1 I want to search for lines which start with pattern2, and add some string in a new line above those matched lines. As a simple example suppose I'm ...
1
vote
2answers
71 views

How do I search for a string in a group of files when some of those files contain spaces?

I'm running Mac 10.7.5. In a terminal, I'll use this command for finding files with strings find src/main -name "*" | xargs grep -i 'mystring' However when the files contain spaces, I'll get ...
1
vote
1answer
47 views

Unhide all .htaccess files on mac

I am trying to unhide all the .htaccess files in my home folder. Below I've pasted what I'm using now, but it isn't working. find ~/ -iname ".htaccess" | xargs chflags nohidden "{}" Anyone knows ...
0
votes
3answers
198 views

Using xargs with find

I want to exclude some directories from searching files and than run the find command to find required files. I am using below command find . -maxdepth 1 -type d | grep -E -i 'sensors' | grep -v ...
4
votes
2answers
189 views

Running find and xargs in background

I want to run this command in background because the process could take a long time. How can I send it to a background process? find /tmp/ -type f -mtime +3 | xargs rm -Rf This does not work: find ...
1
vote
3answers
2k views

Argument list too long for xargs/exec

I'm working on a CentOS server and I have to move around and cat together millions of files. I've tried many incarnations of something like the below, but all of them fail with an argument list too ...
2
votes
3answers
251 views

Using find, xargs, etc. to output similarly named files

I have a folder full of HTML files: 001.htm 002.htm 003.htm … I want to run Pandoc on them to convert them to similarly named Markdown files: 001.md 002.md 003.md This command works on one of ...
0
votes
3answers
374 views

piping output of find to xargs wc gives unreasonable totals

In a project with thousands of files, I wanted to compare total lines-of-code, to lines-of-code just in PHP (discarding CSS, JS, etc). When I run find . -type f | xargs wc -l I the total on the ...
1
vote
3answers
412 views

Difference between xargs /bin/ls and exec ls?

Hi this may be a very newbie question, but why doesnt the xargs /bin/ls work in this case? I thought it was supposed to be faster? Also what are those /fd/3 directories? sh-3.2# find / -name 'GOALS*' ...
0
votes
2answers
181 views

find -print0 | xargs -0 grep not working as expected on Ubuntu 10.04

I've got a bit of a weird issue. If I run: find . -iname '*.php' -o -iname '*.pl' -o -iname '*.html' | xargs grep -i users I get a load of errors for filenames containing spaces, but also some ...
4
votes
1answer
2k views

Create symlinks recursively for a whole tree

I am seeking for a command that would re-create a whole tree of files in a different directory. I would prefer to have all symlinks absolute. Can I do that with a find and xargs? ;-)
1
vote
2answers
649 views

File name with spaces piped to two xargs commands

I have a directory and many more subdirectories like the following - file with spaces.txt filewithsuperlonglines.txt ordinaryfile.txt binaryfile.bin The command - find . -type f -print0 | ...
0
votes
1answer
242 views

find xargs and curl give an error with -C- option

This command works fine find ~/mypath -name *.fstq -print|xargs curl -u sdd:dsdsd ftp://ftp.dsdd.nsdh.com/sdsds/ -T but when I add find ~/mypath -name *.fstq -print|xargs curl -C- -u sdd:dsdsd ...
1
vote
2answers
166 views

Can I simulate ack by using grep with the right combination of options?

I have ack-grep installed on my local machine, and find it indispensable for quickly 'acking' through a codebase when debugging. However, on my cheap shared hosting, there is no ack-grep. One of the ...
0
votes
2answers
107 views

Multiple find by xargs

I have a problem; 1) I'm using find command to find directories; 2) I need to execute another find command in previously found directories. I'want something like this find . -type d -not -name bad | ...
0
votes
2answers
717 views

find Argument list too long

I want to search in many many files for a string. I used find /archive/* -print0 | xargs -0 grep 'robert' -sl Is there a simple method to do it ?
11
votes
5answers
3k views

How to run sed on over 10 million files in a directory?

I have a directory that has 10144911 files in it. So far I've tried the following: for f in ls; do sed -i -e 's/blah/blee/g' $f; done Crashed my shell, the ls is in a tilda but i can't figure out ...
1
vote
4answers
2k views

find with xargs

cat fileNames.txt | xargs find . -name I expect the above command to find the path of every fileName in fileNames.txt, but this command produces no output. Why?
1
vote
1answer
549 views

How to use xargs/find to execute on per file basis

I have some php scrits in a subfolder and want to run some of them (found by a regular expression) via command line. Here is what I have so far: find . -name email[^T]*\.php -print0 | xargs -0 -t ...
2
votes
3answers
2k views

find . -exec grep -l 'string' {} \; -print 2>/dev/null

it lists all files in "." that contain the string "string" but don't show dirs with permission denied. What would it be the equivalent of that but squeezing xargs in between?
1
vote
4answers
157 views

printing matching lines when greping all files in a directory

I'm searching within Java files for some occurrence of a phrase: find . -name '*.java' | xargs grep -l 'string' How do I change this command to print to the shell all of the lines which contain a ...
3
votes
3answers
5k views

How do I use find to copy all found files to a new name in their same directories?

I've got a simple command that does almost what I want. The following will locate all files with a suffix of '_compressed.swf' and copy each into its same directory with a '.bak2' appended: find ...
0
votes
3answers
3k views

Recursive move files of specific type to a specific path

In ~/my/path, I want to move all files that contain string "(J)" and have file type of ".foo" to ~/my/path/j I'm trying: [me ~/my/path]$ find -type f -name "*(J)*.foo" -print0 | xargs mv -0 j/ No ...
7
votes
4answers
7k views

find: -exec vs xargs (aka Why does “find | xargs basename” break?)

I was trying to find all files of a certain type spread out in subdirectories, and for my purposes I only needed the filename. I tried stripping out the path component via basename, but it did't work ...