From f26d5164ae43ab5c03c1e8b82d2553be6f1cb170 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Mon, 16 May 2016 07:51:34 +0100 Subject: [PATCH 1/2] xargs: add example as discussed in #878 Also moved the concrete example to the end. --- pages/common/xargs.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pages/common/xargs.md b/pages/common/xargs.md index e22d2ad6bc..582cd707fd 100644 --- a/pages/common/xargs.md +++ b/pages/common/xargs.md @@ -10,10 +10,14 @@ `{{arguments_null_terminated}} | xargs -0 {{command}}` -- Delete all files that start with 'M': - -`find . -name 'M*' | xargs rm` - - Insert arguments at chosen position, using '%' as the placeholder marker: -`{{arguments}} | xargs -I % {{command}} % {{extra_arguments}}` +`{{arguments}} | xargs -I '%' {{command}} % {{extra_arguments}}` + +- Use the output of one command as arguments to another command: + +`{{command1}} | xargs {{command2}}` + +- Specific example: delete all files that start with 'M': + +`find . -name 'M*' | xargs rm` From 5667133d6a3955a788231091e0cd2bc57ede8ed7 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Mon, 16 May 2016 13:47:00 +0100 Subject: [PATCH 2/2] xargs: move specific example, per discussion in #891 --- pages/common/xargs.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pages/common/xargs.md b/pages/common/xargs.md index 582cd707fd..cbbe3cf704 100644 --- a/pages/common/xargs.md +++ b/pages/common/xargs.md @@ -6,6 +6,10 @@ `{{arguments}} | xargs {{command}}` +- Specific example: delete all files that start with 'M': + +`find . -name 'M*' | xargs rm` + - Handle whitespace in arguments: `{{arguments_null_terminated}} | xargs -0 {{command}}` @@ -13,11 +17,3 @@ - Insert arguments at chosen position, using '%' as the placeholder marker: `{{arguments}} | xargs -I '%' {{command}} % {{extra_arguments}}` - -- Use the output of one command as arguments to another command: - -`{{command1}} | xargs {{command2}}` - -- Specific example: delete all files that start with 'M': - -`find . -name 'M*' | xargs rm`