Tagged Questions
3
votes
3answers
126 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 ...
6
votes
1answer
55 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
74 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
67 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
107 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
81 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
134 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
75 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
4answers
303 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
808 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. ...
4
votes
2answers
374 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
...
6
votes
3answers
1k 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 ...
3
votes
4answers
840 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
197 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
1k 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
2k 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'
...
3
votes
4answers
2k 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 | ...
3
votes
6answers
740 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
629 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 ...
4
votes
4answers
3k 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? Thanks.
3
votes
4answers
986 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
155 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 ...
11
votes
2answers
486 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
3k 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
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 ...
3
votes
2answers
2k 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
805 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 ...
10
votes
2answers
1k 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 ...
