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 |
![]() |
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 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 |
![]() |