Questions tagged [xargs]

xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input.

xargs is a command on Unix and most Unix-like operating systems used to build and execute command lines from standard input. Under the Linux kernel before version 2.6.23, arbitrarily long lists of parameters could not be passed to a command, so xargs breaks the list of arguments into sublists small enough to be acceptable.

xargs often covers the same functionality as the backquote(`) feature of many shells, but is more flexible and often also safer, especially if there are blanks or special characters in the input. It is a good companion for commands that output long lists of files like find, locate and grep, but only if you use -0, since xargs without -0 deals badly with file names containing ', " and space.

1303 questions
0
votes
1 answer

Solaris unix, c-shell, redirecting xargs executed command output

Have no choice about the c-shell. It's what we use here. So I want to parse through current directory and all sub-directories looking for files of form *.utv and egrep each to look for a specific account number in the file. I tried something like…
0
votes
1 answer

excluding .svn .git files from find+xargs+grep pipe

I have an Emacs function (fgf "thing") that creates a subprocess that looks like this: find . \( -type f -a \! -regex '\.(svn|git)' \) -print0 | xargs -0 grep -nH -e 'thing' Basically I don't want grep to look at any of the .git or .svn files. …
gknauth
  • 2,310
  • 2
  • 29
  • 44
0
votes
0 answers

copy over 100 files at a time with xarg or script?

I have over 1.3M files in a dir and I need to move them from j:/hold to j:/hold2 (all while a java app 'watches' the dir for any files to drop in and process them) I cannot just 'rename' the dir because the app crashes because the folder contains…
Docjay
  • 123
  • 3
  • 14
0
votes
0 answers

using xargs in an alias to remove svn unversioned files interactively?

I'm trying to create a bash alias to remove, interactively, all svn unversioned files. I've gotten as far as svn st | grep '^\?'| sed 's/^? //' to get a list of such files. Piping into xargs -p rm just gives me a single prompt for all the…
kslnet
  • 564
  • 8
  • 19
0
votes
2 answers

sed not properly passing stdout to ls

I'm trying to edit a simple string in sed that I've been having issues with. Basically what I'm trying to do is grab my current working directory using pwd, pipe it to sed, edit the file path, then check the file paths contents using ls. The reason…
0
votes
1 answer

xargs with the -d flag, and using substitution, causes an extra "empty" item to be processed

Using the -d flag in xargs to specify a delimter seems to tack an newline after the last value. Either way, it causes the command to break when using substitution to stick the value into the middle of the command (vs the more "standard" way of…
JDS
  • 1,869
  • 1
  • 15
  • 17
0
votes
0 answers

Memory problems with xargs and grep and pattern from file

Within a makefile I run the following command find SOURCE_DIR -name '*.gz' | xargs -P4 -L1 bash -c 'zcat $$1 | grep -F -f <(zcat patternfile.csv.gz) | gzip > TARGET_DIR/$${1##*/}' - patternfile.csv.gz contains 2M entries with an unzipped file size…
Mario Konschake
  • 289
  • 5
  • 14
0
votes
1 answer

Findind files modified during a specified month

I've build this little script for finding files which was modified in a specified month. My script worked fine for this last four years, but from a recent update, now with bash V4, this won't work anymore and I don't understand why. There is the…
techno
  • 525
  • 3
  • 13
0
votes
1 answer

Deleting a lot of keys in Redis

Trying to do something like: # redis-cli keys "resque:lock:*" |xargs -0 redis-cli del xargs: argument line too long What's the best way to work around this?
randombits
  • 47,058
  • 76
  • 251
  • 433
0
votes
2 answers

How to collect all README files and rename them in a folder?

For example, I have these…
Hanfei Sun
  • 45,281
  • 39
  • 129
  • 237
0
votes
4 answers

Select files in a dir that have more than 'n' lines in shell script?

I am trying to select files that have more than 'n' number of lines in a shell script and move them to another directory. The following command works fine from the command line but not in ashell script, MY_PATH='/var/www/' find $MY_PATH -maxdepth 1…
0
votes
2 answers

Why ls command combined with xargs and cp move only 10 files?

I have a command that copies file from one dir to another FILE_COLLECTOR_PATH="/var/www/"; FILE_BACKUP_PATH='/home/' ls $FILE_COLLECTOR_PATH | head -${1} | xargs -i basename {} | xargs -t -i cp $FILE_COLLECTOR_PATH{} "${FILE_BACKUP_PATH}{}-`date…
0
votes
2 answers

To count a character in files by Find/Xargs/Sed

How can you count the number of the character < in your files? I am trying to count the number of the character "<" in my files, similarly as in Vim by %s/
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
0
votes
1 answer

Mailing using Unix with error Files Attached

I have two Files (.csv) say File1.csv and File2.csv with 'INVALID' records, generated at the end of a Informatica Job. I am using below command to search for the file names 'INVALID', and then if either of the file has 'INVALID' records I have to…
0
votes
2 answers

Finding files by creation time of another file

What I need to do is find files by the creation time of another file. For example if i create a file at 9am and later i wanted to find all the files created 1 hour after it or 1 hour before it. How would i do that? I've tried experimenting with…
Nexus490
  • 319
  • 1
  • 4
  • 14