|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I need to direct output of one command as a argument of next command,
but don't know how to do it on command line for example ls -rt | grep sv | tail -1 ---> will give me last modified file. I like to cat on this file. ls -rl | grep sv | tail -1 | cat --> will not do what I am trying to do. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Mon, 03 Sep 2007 06:19:13 -0700
somebody claiming to be JoshforRefugee wrote: > I need to direct output of one command as a argument of next command, > but don't know how to do it on command line > > for example > ls -rt | grep sv | tail -1 ---> will give me last modified file. I > like to cat on this file. > > ls -rl | grep sv | tail -1 | cat --> will not do what I am trying to > do. cat `ls -rl | grep sv | tail -1` Kind regards, Jeroen. -- ir. Jeroen van Nieuwenhuizen Email: jnieuwen [at] jeroen [dot] se I know I'm not perfect but I can smile |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Mon, 03 Sep 2007 06:19:13 -0700
somebody claiming to be JoshforRefugee wrote: > I need to direct output of one command as a argument of next command, > but don't know how to do it on command line > > for example > ls -rt | grep sv | tail -1 ---> will give me last modified file. I > like to cat on this file. > > ls -rl | grep sv | tail -1 | cat --> will not do what I am trying to > do. cat `ls -rl | grep sv | tail -1` Kind regards, Jeroen. -- ir. Jeroen van Nieuwenhuizen Email: jnieuwen [at] jeroen [dot] se I know I'm not perfect but I can smile |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Sep 3, 10:19 pm, JoshforRefugee <anki...@yahoo.com> wrote:
> I need to direct output of one command as a argument of next command, > but don't know how to do it on command line Try using xargs but be careful about spaces in the output of command 1. > for example > ls -rt | grep sv | tail -1 ---> will give me last modified file. I > like to cat on this file. Provided your file names don't have any space within, ls -rt | grep sv | tail -1 | xargs cat |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Thanks Jeroen and Arch119.
One more general question. How can I eliminate additional spaces or is there search and replace I can do on xargs. ls -rt | grep old | tail -1 | s/old/new/ | xargs touch. So in this case, I am grabbing oldest file with *old* name, and creating new file (with replacing old from discovered file name with new) |
|
![]() |
| Outils de la discussion | |
|
|