1

I am writing a bash script and encountered this argument -I in answers here and here but I do not understand what it does. The manual is also not clear to me.

The second answer also states the following text which I also don't understand:

find /thisdir -type f -name "*.ogg" -print0 | xargs -0 -Imysongs mv -i mysongs /somedir 

The -I in the above command tells xargs what replacement string you want to use (otherwise it adds the arguments to the end of the command).

1 Answer 1

2

Yeah, it is kind of roundabout description, but ultimately it is very simple: -I defines a pattern. That pattern would be searched in the remaining of the command line and replaced with an input from stdin.

In the example you shown:

xargs -0 -Imysongs mv -i mysongs /somedir 

The -I defines a pattern "mysongs", that pattern is searched in the rest of command line.

In you example, find produces a list of .ogg files. These files are coming to xarg. So for each file name found by find, the xarg will create and execute command

mv -i <filename> /somedir

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .