Sponsored Content
Full Discussion: Doubt in xargs command
Top Forums Shell Programming and Scripting Doubt in xargs command Post 302548291 by zaxxon on Thursday 18th of August 2011 04:13:01 AM
Old 08-18-2011
It means the following:
Using -i is old, depricated, ie. should be no longer used. Instead, you should use -I. The curled brackets {} is just the string, which should be replaced by the argument which is being handed over to xargs. So you can position it in the line's syntax. You could use other characters but the curled brackets instead. This placeholder is just being defined with -I, example:
Code:
$> echo bla| xargs -I_ touch _
$> ls bla
bla

In this case I just took a single underscore instead of opening and closing curled bracket. Curled brackets are just some kind of "standard" for this most people use because it is or might be easier to read. If there would be more than one usage of the argument in a command's syntax (for example let's say 2), you could use 2 times the _ or {} or whatever character(s) you defined with -I as placeholder in your following command supplied by xargs. Example:
Code:
$> touch file1 file2 file3
$> ls -1
file1
file2
file3
$> ls -1| xargs -I_ mv _ _.txt
$> ls -1
file1.txt
file2.txt
file3.txt

In simple cases where you have just 1 argument being passed to xargs and it should be placed at the end your command, you don't even have to use -I as xargs just places it automatically at the end of the command:
Code:
echo 5| xargs touch

This User Gave Thanks to zaxxon For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

use of xargs command

Hi Everybody, Can you explain the difference between the following commands: 1. find . -print|xargs grep -i dba_2pc_pending 2. find . -print|grep -i dba_2pc_pending (5 Replies)
Discussion started by: kishorebabu
5 Replies

2. Shell Programming and Scripting

xargs doubt

Hi Is there any way to append constant string with arguments generated by xargs.. Like I want to delete some files .. where in I have to add directory also ... ex : echo $fileName | xargs rm $Dir/ValuesFromls Here I have to append Directory name with filename... Shihab (1 Reply)
Discussion started by: shihabvk
1 Replies

3. Shell Programming and Scripting

Xargs command outupt to file

Hello, I'm on a mac trying to have the follow cmd list the files after touch, but very unsuccessful. Please can you help. sort $BOTHFILE | uniq -u | xargs -I {} -t touch {} >> $LOGFILE ; BOTHFile contents in form of /directory/file.txt thanx (3 Replies)
Discussion started by: byblos
3 Replies

4. UNIX for Dummies Questions & Answers

querry about xargs command

what is the real use of xargs command ..? ls -tr |xargs -I{} rm -f {} ....can any one tell me what is the significance of {} curly brackets in this command (1 Reply)
Discussion started by: mobydick
1 Replies

5. Shell Programming and Scripting

xargs command problem

Hi I am trying to use "xargs" command to loop through each file, modify it and overwrite the old file with the modification but with the same file name. I thought it is easy but I just can't get it to work I tried the following I thought {} would give me the current file name, but it... (1 Reply)
Discussion started by: tiger66
1 Replies

6. Shell Programming and Scripting

xargs command

Hi The command below does not work. what I am doing wrong ? For some reason second part of the xargs command is not does what I expect If I get this working I intend to use it for multiple file rename later. echo archDP105144_1_702159963.dbf|xargs -i cp {} `echo {}|awk... (11 Replies)
Discussion started by: zam
11 Replies

7. Shell Programming and Scripting

need help with xargs command..

ls -lrt | awk '$7==12{print $9}' | xargs -i mv {} $dir i executed this command but $dir does not exists....... and the files hv been moved but i dont know where ..... plz help(ASAP) thanks in advance. (8 Replies)
Discussion started by: guptam
8 Replies

8. Shell Programming and Scripting

Pipe output a command to another using xargs

xargs work great when a command gives multiple line output which can be input to another. In my case it is not working coz the second command uses two words in it. $ scr.sh gives output like 193740 638102 375449 .. .. another command takes these number as inputs. it works great... (1 Reply)
Discussion started by: mahesh113
1 Replies

9. Shell Programming and Scripting

Looking for XARGS command Silent options

ls | grep -E '^+$' | xargs --verbose -I{} rm -vfr "{}"; When i execute the command it works fine by removing the directories and its writing the output as below about which files are deleting.What i want know is,is there any XARGS command option that it should done silently in background with... (2 Replies)
Discussion started by: nareshreddy443
2 Replies

10. UNIX for Beginners Questions & Answers

Xargs -P command execution status

Hi, I am working on a file copier utility where I have written the copy commands to a batch file e.g. file_copier.bat which i pass to xargs command as follows. cat file_copier.bat | xargs -n 1 -P 40 I also want to record the copy command status of each file/command in the form "command... (1 Reply)
Discussion started by: ankur singh
1 Replies
GIT-PACK-REDUNDANT(1)						    Git Manual						     GIT-PACK-REDUNDANT(1)

NAME
git-pack-redundant - Find redundant pack files SYNOPSIS
git pack-redundant [ --verbose ] [ --alt-odb ] < --all | .pack filename ... > DESCRIPTION
This program computes which packs in your repository are redundant. The output is suitable for piping to xargs rm if you are in the root of the repository. git pack-redundant accepts a list of objects on standard input. Any objects given will be ignored when checking which packs are required. This makes the following command useful when wanting to remove packs which contain unreachable objects. git fsck --full --unreachable | cut -d ' ' -f3 | git pack-redundant --all | xargs rm OPTIONS
--all Processes all packs. Any filenames on the command line are ignored. --alt-odb Don't require objects present in packs from alternate object directories to be present in local packs. --verbose Outputs some statistics to stderr. Has a small performance penalty. SEE ALSO
git-pack-objects(1) git-repack(1) git-prune-packed(1) GIT
Part of the git(1) suite Git 1.8.3.1 06/10/2014 GIT-PACK-REDUNDANT(1)
All times are GMT -4. The time now is 10:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy