|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
"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. |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
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. |
|
![]() |
| Outils de la discussion | |
|
|