Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2445 connectés 

  FORUM HardWare.fr
  Linux et OS Alternatifs
  Codes et scripts

  [BASH] - Formater la sortie avec echo ou printf ? (RESOLU)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[BASH] - Formater la sortie avec echo ou printf ? (RESOLU)

n°1220633
lebarjoe
Posté le 30-05-2010 à 22:17:07  profilanswer
 

Bonjour,
 
Je souhaiterai formater le résultat d'une commande, ci-dessous un exemple de programme :
 

Code :
  1. desktop:/etc/X11$ CMDLINE='ls -al'
  2. desktop:/etc/X11$ RESULT=$($CMDLINE)
  3. desktop:/etc/X11$ echo -e "\t\t$RESULT\n"
  4.  total 100
  5. drwxr-xr-x  10 root root  4096 2010-05-30 12:33 .
  6. drwxr-xr-x 128 root root 12288 2010-05-30 22:00 ..
  7. drwxr-xr-x   2 root root  4096 2010-04-29 14:27 app-defaults
  8. drwxr-xr-x   2 root root  4096 2010-04-29 14:27 cursors
  9. -rw-r--r--   1 root root    14 2010-04-29 14:28 default-display-manager
  10. drwxr-xr-x   6 root root  4096 2010-04-29 14:25 fonts
  11. -rw-r--r--   1 root root 17394 2009-12-03 11:56 rgb.txt
  12. lrwxrwxrwx   1 root root    13 2010-05-29 13:26 X -> /usr/bin/Xorg
  13. drwxr-xr-x   3 root root  4096 2010-04-29 14:27 xinit
  14. drwxr-xr-x   2 root root  4096 2010-04-15 14:12 xkb
  15. -rw-r--r--   1 root root  2614 2010-05-30 12:33 xorg.conf
  16. -rw-r--r--   1 root root  2573 2010-05-30 10:34 xorg.conf-backup-100530103356
  17. -rw-r--r--   1 root root   269 2010-05-30 10:33 xorg.conf.failsafe
  18. -rwxr-xr-x   1 root root   709 2010-04-01 13:19 Xreset
  19. drwxr-xr-x   2 root root  4096 2010-04-29 14:20 Xreset.d
  20. drwxr-xr-x   2 root root  4096 2010-04-29 14:20 Xresources
  21. -rwxr-xr-x   1 root root  3730 2010-04-01 13:07 Xsession
  22. drwxr-xr-x   2 root root  4096 2010-05-30 12:38 Xsession.d
  23. -rw-r--r--   1 root root   265 2008-07-01 19:41 Xsession.options
  24. -rw-------   1 root root   601 2010-04-29 14:20 Xwrapper.config


 
En gros, le résultat que j'attend, c'est que toutes les lignes subissent une double tabulation.
 
Comment faire sans passer par un fichier ?
 
Merci d'avance de votre retour.


Message édité par lebarjoe le 01-06-2010 à 09:06:21
mood
Publicité
Posté le 30-05-2010 à 22:17:07  profilanswer
 

n°1220895
lebarjoe
Posté le 01-06-2010 à 09:05:48  profilanswer
 

J'ai trouvé :
 

Code :
  1. echo -e "$RESULT\n" | awk '{print "\t\t",$0}'


Message édité par lebarjoe le 01-06-2010 à 09:06:47

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs
  Codes et scripts

  [BASH] - Formater la sortie avec echo ou printf ? (RESOLU)

 

Sujets relatifs
pb ldap glpi (résolu)[RESOLU] Installer PHPLIST sur Debian Lenny
Perte de connexion wifi et ethernet depuis une Debian Lenny (résolu)Résolu [DHCP] option routers ignoré par le client ou plutot l'inverse.
Knoppix + LXDE / mapage clavier [résolu][Résolu] Exécuter un script après mise à jour de certains paquets
Creative X-fi 5.1 et sortie spdif numeriqueserveur dédié / gentoo / configuration de sendmail [résolu]
[RESOLU] redhat enterprise versus centos sur VM[Résolu ^^'] Monter un partage Windows 2003 sur client Ubuntu
Plus de sujets relatifs à : [BASH] - Formater la sortie avec echo ou printf ? (RESOLU)


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR