f



xargs dry run.

how can i make xargs just to display the command it is going to run and actually run it. For the following command.

$ ls -1t | sed -n '1p' | xargs -I % scp % username@hostname:/tmp

I tried adding echo, while it works for simple commands, but it doesn't work for the above command.

$ ls -1t | sed -n '1p' | xargs echo -I % scp % username@ohostname:/tmp

-I % scp % username@hostname:/tmp filname
0
sinbad
12/22/2016 9:06:20 AM
comp.unix.programmer 10848 articles. 0 followers. kokososo56 (349) is leader. Post Follow

2 Replies
101 Views

Similar Articles

[PageSpeed] 36

On 22/12/2016 20:06, sinbad wrote:
> how can i make xargs just to display the command it is going to run and actually run it. For the following command.
>
> $ ls -1t | sed -n '1p' | xargs -I % scp % username@hostname:/tmp
>
> I tried adding echo, while it works for simple commands, but it doesn't work for the above command.
>
> $ ls -1t | sed -n '1p' | xargs echo -I % scp % username@ohostname:/tmp
>
> -I % scp % username@hostname:/tmp filname
>
The "-I" is an option to xargs, not echo.

Try:
$ ls -1t | sed -n '1p' | xargs -I % echo scp % username@ohostname:/tmp

	Cheers,
		Gary	B-)

-- 
When men talk to their friends, they insult each other.
They don't really mean it.
When women talk to their friends, they compliment each other.
They don't mean it either.
0
Gary
12/22/2016 9:29:33 AM
"Gary R. Schmidt" <grschmidt@acm.org> writes:
> On 22/12/2016 20:06, sinbad wrote:
>> how can i make xargs just to display the command it is going to run and actually run it. For the following command.
>>
>> $ ls -1t | sed -n '1p' | xargs -I % scp % username@hostname:/tmp
>>
>> I tried adding echo, while it works for simple commands, but it doesn't work for the above command.
>>
>> $ ls -1t | sed -n '1p' | xargs echo -I % scp % username@ohostname:/tmp
>>
>> -I % scp % username@hostname:/tmp filname
>>
> The "-I" is an option to xargs, not echo.
>
> Try:
> $ ls -1t | sed -n '1p' | xargs -I % echo scp % username@ohostname:/tmp

This is the same as

ls -t | sed 'q' | xargs -I % echo scp % username@ohostname:/tmp

!

[SCNR]
0
Rainer
12/22/2016 4:54:20 PM
Reply: