Re: combine two commands via pipe

2024-07-25 Thread coreyh
So, in summary, the glob solution: * Is shorter. * Is easier to read and understand. * Is more efficient. * Doesn't break if someone creates /tmp/apache420. I know few about glob. But after checking the man page I think it is a good idea. Many thanks! -- corey hickman

Re: combine two commands via pipe

2024-07-25 Thread Greg Wooledge
On Fri, Jul 26, 2024 at 09:44:52 +0700, Max Nikulin wrote: > https://mywiki.wooledge.org/BashPitfalls#for_f_in_.24.28ls_.2A.mp3.29 > for f in $(ls *.mp3) > No 1 in Bash Pitfalls I added nicer anchors, which you can use if you prefer: https://mywiki.wooledge.org/BashPitfalls#pf1 The auto-gene

Re: combine two commands via pipe

2024-07-25 Thread Max Nikulin
On 26/07/2024 09:25, Andy Smith wrote: On Fri, Jul 26, 2024 at 10:00:48AM +0800, cor...@free.fr wrote: $ sudo ls -ltr "/tmp/$(ls /tmp |grep apache)" [...] So what is wrong with just using a glob as suggested? Not all people are realizing how many pitfalls they may face using shell. (I admit

Re: combine two commands via pipe

2024-07-25 Thread Andy Smith
Hi, On Fri, Jul 26, 2024 at 10:00:48AM +0800, cor...@free.fr wrote: > I found this works though it's ugly. > > $ sudo ls -ltr "/tmp/$(ls /tmp |grep apache)" > total 4 > > Thanks for all help. If you appreciate help then engage with it. Two people now have suggested that you just use a glob, and

Re: combine two commands via pipe

2024-07-25 Thread Greg Wooledge
On Fri, Jul 26, 2024 at 10:00:48 +0800, cor...@free.fr wrote: > I found this works though it's ugly. > > $ sudo ls -ltr "/tmp/$(ls /tmp |grep apache)" > total 4 Just use a glob. sudo ls -ltr /tmp/*apache*

Re: combine two commands via pipe

2024-07-25 Thread coreyh
I found this works though it's ugly. $ sudo ls -ltr "/tmp/$(ls /tmp |grep apache)" total 4 Thanks for all help. On 2024-07-26 09:42, Max Nikulin wrote: On 26/07/2024 06:59, cor...@free.fr wrote: My actual requirement is that I want to 'ls -ltr' into a subdir in /tmp. that subdir is apache's

Re: combine two commands via pipe

2024-07-25 Thread Max Nikulin
On 26/07/2024 06:59, cor...@free.fr wrote: My actual requirement is that I want to 'ls -ltr' into a subdir in /tmp. that subdir is apache's tmp dir. but the name of the subdir is too long (hard to copy&paste), so I am looking for a easier way. Use glob if it is acceptable sudo ls -ltr /tmp/

Re: combine two commands via pipe

2024-07-25 Thread coreyh
There is only one subdir exists with chars ‘apache’ included in /tmp. Regards On 2024-07-26 08:14, Greg Wooledge wrote: On Fri, Jul 26, 2024 at 07:59:42 +0800, cor...@free.fr wrote: > > I won't go any fancier than this until I know it's actually needed. My actual requirement is that I want t

Re: combine two commands via pipe

2024-07-25 Thread Greg Wooledge
On Fri, Jul 26, 2024 at 07:59:42 +0800, cor...@free.fr wrote: > > > > > I won't go any fancier than this until I know it's actually needed. > > My actual requirement is that I want to 'ls -ltr' into a subdir in /tmp. > that subdir is apache's tmp dir. but the name of the subdir is too long > (ha

Re: combine two commands via pipe

2024-07-25 Thread coreyh
I won't go any fancier than this until I know it's actually needed. My actual requirement is that I want to 'ls -ltr' into a subdir in /tmp. that subdir is apache's tmp dir. but the name of the subdir is too long (hard to copy&paste), so I am looking for a easier way. Thank you. -- core

Re: combine two commands via pipe

2024-07-25 Thread mick.crane
On 2024-07-26 00:44, Alain D D Williams wrote: On Fri, Jul 26, 2024 at 07:29:10AM +0800, cor...@free.fr wrote: this could work indeed. but it requires me to input a long path. so I am asking for a easier way. Try this: $ sudo find /tmp -user apache2 I've recently been using catfish to sea

Re: combine two commands via pipe

2024-07-25 Thread Greg Wooledge
On Fri, Jul 26, 2024 at 07:29:10 +0800, cor...@free.fr wrote: > On 2024-07-26 07:14, Alain D D Williams wrote: > > Neither do you say what you are trying to achieve. Looking for files > > owned by > > apache in a directory ? > > yes. Does "owned by apache" mean literally the user "apache"? Or is

Re: combine two commands via pipe

2024-07-25 Thread Alain D D Williams
On Fri, Jul 26, 2024 at 07:29:10AM +0800, cor...@free.fr wrote: > this could work indeed. but it requires me to input a long path. so I am > asking for a easier way. Try this: $ sudo find /tmp -user apache2 -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programme

Re: combine two commands via pipe

2024-07-25 Thread coreyh
On 2024-07-26 07:14, Alain D D Williams wrote: On Fri, Jul 26, 2024 at 07:04:37AM +0800, cor...@free.fr wrote: Hello gurus, I have the following commands: $ ls /tmp/|grep apache2 systemd-private-653536fdd8d04538ab68da7469570d0c-apache2.service-UiHjaL $ sudo ls -ltr /tmp/systemd-private-653536

combine two commands via pipe

2024-07-25 Thread coreyh
Hello gurus, I have the following commands: $ ls /tmp/|grep apache2 systemd-private-653536fdd8d04538ab68da7469570d0c-apache2.service-UiHjaL $ sudo ls -ltr /tmp/systemd-private-653536fdd8d04538ab68da7469570d0c-apache2.service-UiHjaL total 4 When I tried to run them in one line as follows, $