PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > cat
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

cat

Réponse
 
LinkBack Outils de la discussion
Vieux 07/01/2008, 06h24   #1
sant527@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut cat

I have a list of files

SLOg1.htm
SLOg10.htm
SLOg11.htm
SLOg12.htm
SLOg13.htm
SLOg14.htm
SLOg15.htm
SLOg16-18.htm
SLOg16.htm
SLOg17.htm
SLOg18.htm
SLOg19.htm
SLOg2.htm
SLOg20.htm
SLOg21-22.htm
SLOg21.htm
SLOg22.htm
SLOg23.htm
SLOg24.htm
SLOg25.htm
SLOg26.htm
SLOg27.htm
SLOg28.htm
SLOg29.htm
SLOg3.htm

I am using the command cat SLO* > hare.htm

The problem is the sequence of appending is shown above rather than
SLOg1.htm SLOg2.htm Slog3.htm .....

How can append as per the ascending file name patter.
  Réponse avec citation
Vieux 07/01/2008, 07h16   #2
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

On 2008-01-07, sant527@gmail.com <sant527@gmail.com> wrote:
>
>
> I have a list of files
>
> SLOg1.htm
> SLOg10.htm
> SLOg11.htm
> SLOg12.htm
> SLOg13.htm
> SLOg14.htm
> SLOg15.htm
> SLOg16-18.htm
> SLOg16.htm
> SLOg17.htm
> SLOg18.htm
> SLOg19.htm
> SLOg2.htm
> SLOg20.htm
> SLOg21-22.htm
> SLOg21.htm
> SLOg22.htm
> SLOg23.htm
> SLOg24.htm
> SLOg25.htm
> SLOg26.htm
> SLOg27.htm
> SLOg28.htm
> SLOg29.htm
> SLOg3.htm
>
> I am using the command cat SLO* > hare.htm
>
> The problem is the sequence of appending is shown above rather than
> SLOg1.htm SLOg2.htm Slog3.htm .....
>
> How can append as per the ascending file name patter.


cat SLOg?.htm SLOg??.htm
I'm not sure where you'd want to put SLOg16-18.htm or SLOg21-22.htm or
other hyphenated files. You could create a list in the order you want
and do
while read file; do
cat "$file" >> hare.htm
done < listfile
  Réponse avec citation
Vieux 07/01/2008, 07h30   #3
sant527@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

On Jan 7, 12:16 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On 2008-01-07, sant...@gmail.com <sant...@gmail.com> wrote:
>
>
>
>
>
> > I have a list of files

>
> > SLOg1.htm
> > SLOg10.htm
> > SLOg11.htm
> > SLOg12.htm
> > SLOg13.htm
> > SLOg14.htm
> > SLOg15.htm
> > SLOg16-18.htm
> > SLOg16.htm
> > SLOg17.htm
> > SLOg18.htm
> > SLOg19.htm
> > SLOg2.htm
> > SLOg20.htm
> > SLOg21-22.htm
> > SLOg21.htm
> > SLOg22.htm
> > SLOg23.htm
> > SLOg24.htm
> > SLOg25.htm
> > SLOg26.htm
> > SLOg27.htm
> > SLOg28.htm
> > SLOg29.htm
> > SLOg3.htm

>
> > I am using the command cat SLO* > hare.htm

>
> > The problem is the sequence of appending is shown above rather than
> > SLOg1.htm SLOg2.htm Slog3.htm .....

>
> > How can append as per the ascending file name patter.

>
> cat SLOg?.htm SLOg??.htm
> I'm not sure where you'd want to put SLOg16-18.htm or SLOg21-22.htm or
> other hyphenated files. You could create a list in the order you want
> and do
> while read file; do
> cat "$file" >> hare.htm
> done < listfile


But in windows the files are being selected as per I desire. Why not
unix
  Réponse avec citation
Vieux 07/01/2008, 08h04   #4
sant527@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

On Jan 7, 12:30 pm, "sant...@gmail.com" <sant...@gmail.com> wrote:
> On Jan 7, 12:16 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:
>
>
>
> > On 2008-01-07, sant...@gmail.com <sant...@gmail.com> wrote:

>
> > > I have a list of files

>
> > > SLOg1.htm
> > > SLOg10.htm
> > > SLOg11.htm
> > > SLOg12.htm
> > > SLOg13.htm
> > > SLOg14.htm
> > > SLOg15.htm
> > > SLOg16-18.htm
> > > SLOg16.htm
> > > SLOg17.htm
> > > SLOg18.htm
> > > SLOg19.htm
> > > SLOg2.htm
> > > SLOg20.htm
> > > SLOg21-22.htm
> > > SLOg21.htm
> > > SLOg22.htm
> > > SLOg23.htm
> > > SLOg24.htm
> > > SLOg25.htm
> > > SLOg26.htm
> > > SLOg27.htm
> > > SLOg28.htm
> > > SLOg29.htm
> > > SLOg3.htm

>
> > > I am using the command cat SLO* > hare.htm

>
> > > The problem is the sequence of appending is shown above rather than
> > > SLOg1.htm SLOg2.htm Slog3.htm .....

>
> > > How can append as per the ascending file name patter.

>
> > cat SLOg?.htm SLOg??.htm
> > I'm not sure where you'd want to put SLOg16-18.htm or SLOg21-22.htm or
> > other hyphenated files. You could create a list in the order you want
> > and do
> > while read file; do
> > cat "$file" >> hare.htm
> > done < listfile

>
> But in windows the files are being selected as per I desire. Why not
> unix


Is there no any other way so that I can do the things easily
  Réponse avec citation
Vieux 07/01/2008, 08h18   #5
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

On Sun, 6 Jan 2008 23:30:23 -0800 (PST), sant527@gmail.com wrote:
[...]
>> > SLOg1.htm
>> > SLOg10.htm
>> > SLOg11.htm
>> > SLOg12.htm
>> > SLOg13.htm
>> > SLOg14.htm
>> > SLOg15.htm
>> > SLOg16-18.htm
>> > SLOg16.htm
>> > SLOg17.htm
>> > SLOg18.htm
>> > SLOg19.htm
>> > SLOg2.htm
>> > SLOg20.htm
>> > SLOg21-22.htm
>> > SLOg21.htm
>> > SLOg22.htm
>> > SLOg23.htm
>> > SLOg24.htm
>> > SLOg25.htm
>> > SLOg26.htm
>> > SLOg27.htm
>> > SLOg28.htm
>> > SLOg29.htm
>> > SLOg3.htm

>>
>> > I am using the command cat SLO* > hare.htm

>>
>> > The problem is the sequence of appending is shown above rather than
>> > SLOg1.htm SLOg2.htm Slog3.htm .....

>>
>> > How can append as per the ascending file name patter.

>>
>> cat SLOg?.htm SLOg??.htm
>> I'm not sure where you'd want to put SLOg16-18.htm or SLOg21-22.htm or
>> other hyphenated files. You could create a list in the order you want
>> and do
>> while read file; do
>> cat "$file" >> hare.htm
>> done < listfile

>
> But in windows the files are being selected as per I desire. Why not
> unix


Must be a bug in Windows. SLOg10.html is before SLOg2.htm in
lexical order.

With the zsh shell, you can specify the sorting order. For a
numerical sort:

cat SLO*(n) > hare.htm

You can also sort according to the date of last modification:

cat SLO*(Om) > hare.htm

will concatenate the files starting from the oldest and to the
newest.

The part inside (...) is called globbing qualifiers in zsh. The
"o" is for "odering", capital O is for reverse order, it's
followed by a letter that specifies the ordering method. By
default, zsh sorts by name so that cat SLO* is like cat SLO*(on)
om, is to [o]rder by [m]odification time. "n" is another
globbing qualifier that further qualifies the sorting by name
and specifies a numerical sorting. (n) is like (non).

The GNU implementation of ls has a "-v" option to sort by
"version" number, so you can do:

eval "cat < /dev/null $(ls -v --quoting-stype=shell LOG*)" > hare.htm

"< /dev/null" is to prevent that command from hanging if there's
no matching file.

--
Stephane
  Réponse avec citation
Vieux 07/01/2008, 09h19   #6
sant527@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

On Jan 7, 1:18 pm, Stephane Chazelas <stephane_chaze...@yahoo.fr>
wrote:
> On Sun, 6 Jan 2008 23:30:23 -0800 (PST), sant...@gmail.com wrote:
>
> [...]
>
>
>
> >> > SLOg1.htm
> >> > SLOg10.htm
> >> > SLOg11.htm
> >> > SLOg12.htm
> >> > SLOg13.htm
> >> > SLOg14.htm
> >> > SLOg15.htm
> >> > SLOg16-18.htm
> >> > SLOg16.htm
> >> > SLOg17.htm
> >> > SLOg18.htm
> >> > SLOg19.htm
> >> > SLOg2.htm
> >> > SLOg20.htm
> >> > SLOg21-22.htm
> >> > SLOg21.htm
> >> > SLOg22.htm
> >> > SLOg23.htm
> >> > SLOg24.htm
> >> > SLOg25.htm
> >> > SLOg26.htm
> >> > SLOg27.htm
> >> > SLOg28.htm
> >> > SLOg29.htm
> >> > SLOg3.htm

>
> >> > I am using the command cat SLO* > hare.htm

>
> >> > The problem is the sequence of appending is shown above rather than
> >> > SLOg1.htm SLOg2.htm Slog3.htm .....

>
> >> > How can append as per the ascending file name patter.

>
> >> cat SLOg?.htm SLOg??.htm
> >> I'm not sure where you'd want to put SLOg16-18.htm or SLOg21-22.htm or
> >> other hyphenated files. You could create a list in the order you want
> >> and do
> >> while read file; do
> >> cat "$file" >> hare.htm
> >> done < listfile

>
> > But in windows the files are being selected as per I desire. Why not
> > unix

>
> Must be a bug in Windows. SLOg10.html is before SLOg2.htm in
> lexical order.
>
> With the zsh shell, you can specify the sorting order. For a
> numerical sort:
>
> cat SLO*(n) > hare.htm
>
> You can also sort according to the date of last modification:
>
> cat SLO*(Om) > hare.htm
>
> will concatenate the files starting from the oldest and to the
> newest.
>
> The part inside (...) is called globbing qualifiers in zsh. The
> "o" is for "odering", capital O is for reverse order, it's
> followed by a letter that specifies the ordering method. By
> default, zsh sorts by name so that cat SLO* is like cat SLO*(on)
> om, is to [o]rder by [m]odification time. "n" is another
> globbing qualifier that further qualifies the sorting by name
> and specifies a numerical sorting. (n) is like (non).
>
> The GNU implementation of ls has a "-v" option to sort by
> "version" number, so you can do:
>
> eval "cat < /dev/null $(ls -v --quoting-stype=shell LOG*)" > hare.htm
>
> "< /dev/null" is to prevent that command from hanging if there's
> no matching file.
>
> --
> Stephane


Thanks

cat $(ls -v SLO*) > SLOKA.htm

It works
  Réponse avec citation
Vieux 07/01/2008, 09h32   #7
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

On Mon, 7 Jan 2008 01:19:58 -0800 (PST), sant527@gmail.com wrote:
[...]
>> eval "cat < /dev/null $(ls -dv --quoting-stype=shell LOG*)" > hare.htm

[...]
> cat $(ls -v SLO*) > SLOKA.htm


Note that that only works if none of the file names contain SPC,
TAB, NL. *, ? or [ characters, hence my usage of eval and
--quoting-style=shell.

--
Stephane
  Réponse avec citation
Vieux 07/01/2008, 12h20   #8
Maxwell Lol
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

"sant527@gmail.com" <sant527@gmail.com> writes:

> I have a list of files
>
> SLOg1.htm
> SLOg10.htm


If I can, i use names that sort well, i.e. SLOg01.htm instead of
SLOg1.htm If it has a date in the name, I use YYMMDD so the default
sort is always chronological.

  Réponse avec citation
Vieux 07/01/2008, 13h25   #9
Teddy
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

Below is simple script you could use that.
Also I belive this could be done in awk using tagged regular
expression but I dont know much about it. I am newbie to UNIX.


#!/bin/ksh

COUNTER="1"

while(true)
do
cat slg${COUNTER}.htm >> hare.htm
let COUNTER=COUNTER+1
file slg${COUNTER}.htm
if [[ -f slg${COUNTER}.htm && ! -d slg${COUNTER}.htm && -r slg$
{COUNTER}.htm ]]
then
continue
else
break
fi
done
  Réponse avec citation
Vieux 07/01/2008, 13h36   #10
Cyrus Kriticos
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: cat

Teddy wrote:
> Below is simple script you could use that.
> Also I belive this could be done in awk using tagged regular
> expression but I dont know much about it. I am newbie to UNIX.
>
>
> #!/bin/ksh
>
> COUNTER="1"
>
> while(true)
> do
> cat slg${COUNTER}.htm >> hare.htm
> let COUNTER=COUNTER+1
> file slg${COUNTER}.htm
> if [[ -f slg${COUNTER}.htm && ! -d slg${COUNTER}.htm && -r slg$
> {COUNTER}.htm ]]
> then
> continue
> else
> break
> fi
> done




sant527@gmail.com wrote:
> [...]
> SLOg16-18.htm
> [...]
> SLOg21-22.htm


--
Best regards | Be nice to America or they'll bring democracy to
Cyrus | your country.
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h29.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19675 seconds with 18 queries