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 > Concat list of files (ls)
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Concat list of files (ls)

Réponse
 
LinkBack Outils de la discussion
Vieux 01/12/2006, 10h39   #1
J_Zanetti
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Concat list of files (ls)

Hello everybody,

I need to concat the results of two distinct lists of file and make one
unique list.
Something like that:

list1='ls .txt'
list2='ls .xml'

I would like to have list = list1 + list2 (and then use the elements of
list) but i cannot find the right command to do that.
Note that the list1 and list 2 are retrieved in different part of a
code (otherwise i would use a unique command).

Thanks!

  Réponse avec citation
Vieux 01/12/2006, 12h12   #2
Bo Yang
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat list of files (ls)

J_Zanetti :
> Hello everybody,
>
> I need to concat the results of two distinct lists of file and make one
> unique list.
> Something like that:
>
> list1='ls .txt'
> list2='ls .xml'
>
> I would like to have list = list1 + list2 (and then use the elements of
> list) but i cannot find the right command to do that.
> Note that the list1 and list 2 are retrieved in different part of a
> code (otherwise i would use a unique command).


Is
echo $list1 $list2 | sort | unique
OK?
  Réponse avec citation
Vieux 01/12/2006, 13h17   #3
J_Zanetti
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat list of files (ls)

Bo Yang ha scritto:
> Is
> echo $list1 $list2 | sort | unique
> OK?


It works ! thanks

  Réponse avec citation
Vieux 01/12/2006, 14h06   #4
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat list of files (ls)

Bo Yang wrote:
> J_Zanetti :
>
>>Hello everybody,
>>
>>I need to concat the results of two distinct lists of file and make one
>>unique list.
>>Something like that:
>>
>>list1='ls .txt'
>>list2='ls .xml'
>>
>>I would like to have list = list1 + list2 (and then use the elements of
>>list) but i cannot find the right command to do that.
>>Note that the list1 and list 2 are retrieved in different part of a
>>code (otherwise i would use a unique command).

>
>
> Is
> echo $list1 $list2 | sort | unique
> OK?


a) quote your variables
b) sort has a -u option

Ed.
  Réponse avec citation
Vieux 01/12/2006, 14h35   #5
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat list of files (ls)

On 2006-12-01, J_Zanetti wrote:
> Hello everybody,
>
> I need to concat the results of two distinct lists of file and make one
> unique list.
> Something like that:
>
> list1='ls .txt'
> list2='ls .xml'


Do you mean:

list1=`ls *.txt`
list2=`ls *.xml`

> I would like to have list = list1 + list2 (and then use the elements of
> list) but i cannot find the right command to do that.
> Note that the list1 and list 2 are retrieved in different part of a
> code (otherwise i would use a unique command).


list3="$list1
$list2"

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 01/12/2006, 14h38   #6
Bo Yang
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Concat list of files (ls)

Ed Morton
> Bo Yang wrote:
>> J_Zanetti :
>>
>>> Hello everybody,
>>>
>>> I need to concat the results of two distinct lists of file and make one
>>> unique list.
>>> Something like that:
>>>
>>> list1='ls .txt'
>>> list2='ls .xml'
>>>
>>> I would like to have list = list1 + list2 (and then use the elements of
>>> list) but i cannot find the right command to do that.
>>> Note that the list1 and list 2 are retrieved in different part of a
>>> code (otherwise i would use a unique command).

>>
>>
>> Is
>> echo $list1 $list2 | sort | unique
>> OK?

>
> a) quote your variables
> b) sort has a -u option
>
> Ed.

Thank you!
  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 22h15.


É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,55465 seconds with 14 queries