From: moonhkt on
Hi All

I have below files, each backup have date code after it.
moonhkt
moonhkt.20100405
moonhkt.20100406
moonhkt.ksh
moonhkt.ksh.20100406
moonhkt.p
moonhkt.p.20100405


how to ls or other command display moonhkt and its backup file ?
output as below
moonhkt
moonhkt.20100405
moonhkt.20100406



moonhkt




From: Bit Twister on
On Thu, 13 May 2010 06:59:20 -0700 (PDT), moonhkt wrote:
> Hi All
>
> I have below files, each backup have date code after it.
> moonhkt
> moonhkt.20100405
> moonhkt.20100406
> moonhkt.ksh
> moonhkt.ksh.20100406
> moonhkt.p
> moonhkt.p.20100405
>
>
> how to ls or other command display moonhkt and its backup file ?
> output as below
> moonhkt
> moonhkt.20100405
> moonhkt.20100406

ls -1 moonhkt moonhkt.2???????
From: Chris F.A. Johnson on
On 2010-05-13, moonhkt wrote:
> Hi All
>
> I have below files, each backup have date code after it.
> moonhkt
> moonhkt.20100405
> moonhkt.20100406
> moonhkt.ksh
> moonhkt.ksh.20100406
> moonhkt.p
> moonhkt.p.20100405
>
>
> how to ls or other command display moonhkt and its backup file ?
> output as below
> moonhkt
> moonhkt.20100405
> moonhkt.20100406

printf "%s\n" moonhkt moonhkt.[0-9]*

--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
===== My code in this post, if any, assumes the POSIX locale =====
===== and is released under the GNU General Public Licence =====
From: moonhkt on
On 5¤ë13¤é, ¤U¤È10®É40¤À, "Chris F.A. Johnson" <cfajohn...(a)gmail.com> wrote:
> On 2010-05-13, moonhkt wrote:
> > Hi All
>
> > I have below files, each backup have date code after it.
> > moonhkt
> > moonhkt.20100405
> > moonhkt.20100406
> > moonhkt.ksh
> > moonhkt.ksh.20100406
> > moonhkt.p
> > moonhkt.p.20100405
>
> > how to ls or other command display moonhkt and its backup file ?
> > output as below
> > moonhkt
> > moonhkt.20100405
> > moonhkt.20100406
>
> printf "%s\n" moonhkt moonhkt.[0-9]*
>
> --
> Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
> ===================================================================
> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
> ===== My code in this post, if any, assumes the POSIX locale =====
> ===== and is released under the GNU General Public Licence =====- ÁôÂóQ¤Þ¥Î¤å¦r -
>
> - Åã¥Ü³Q¤Þ¥Î¤å¦r -

Thank try OK. But how printf works ? How printf list of current
directory ?

ls -lt moonhkt moonhkt.[0-9]*

-rw-rw---- 1 moonhkt al 0 May 12 11:58 moonhkt
-rw-rw---- 1 moonhkt al 0 May 02 13:00 moonhkt.
20100502_1300icm
-rw-rw---- 1 moonhkt al 0 May 02 12:22 moonhkt.
20100502_1222icm
-rw-rw---- 1 moonhkt al 0 Apr 02 13:00 moonhkt.
20100402_1300icm


printf "%s\n" moonhkt moonhkt.[0-9]*
moonhkt
moonhkt.20100402_1300icm
moonhkt.20100502_1222icm
moonhkt.20100502_1300icm


From: Chris F.A. Johnson on
On 2010-05-14, moonhkt wrote:
> On 5??13??, ?U??10??40??, "Chris F.A. Johnson" <cfajohn...(a)gmail.com> wrote:
>> On 2010-05-13, moonhkt wrote:
>> > Hi All
>>
>> > I have below files, each backup have date code after it.
>> > moonhkt
>> > moonhkt.20100405
>> > moonhkt.20100406
>> > moonhkt.ksh
>> > moonhkt.ksh.20100406
>> > moonhkt.p
>> > moonhkt.p.20100405
>>
>> > how to ls or other command display moonhkt and its backup file ?
>> > output as below
>> > moonhkt
>> > moonhkt.20100405
>> > moonhkt.20100406
>>
>> printf "%s\n" moonhkt moonhkt.[0-9]*
>
> Thank try OK. But how printf works ? How printf list of current
> directory ?

The shell expands the arguments and printf just prints them.

There is no reason to use ls without any options. (Someone will
probably come up with a case, but generally ls isn't necessary
unless you are using at least one option.)

--
Chris F.A. Johnson, author <http://shell.cfajohnson.com/>
===================================================================
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
===== My code in this post, if any, assumes the POSIX locale =====
===== and is released under the GNU General Public Licence =====