Shell

Bonjour,
comment je peut creé un texte sous shell sans fait appel a un editeur de texte et comment je supprime la première ligne d'un fichier texte
Configuration: Windows Vista / Firefox 3.5.8

10 réponses

  1. Tu serais pas sous windows par hasard ??
    Sinon tu fais
    echo le_texte_à_taper > le_fichier_dans_lequel_ecrire
    1. Ah ok ... C'est quand j'ai vu le " Configuration: Windows Vista / Firefox 3.5.8 "
      Sinon tu as essayé echo pour ton problème d'écriture ?
      1. comment je peut supprimer la première ligne dans cet cas s'il vous plait
        1. vi tonfichier
          met toi sur la ligne que tu veux supprimer et fait 2 fois d c-a-d tu tape d et tu retape d, la ligne serra suprimer apres tu fait :qw (qw = save and exit) si tu fait une erreur fait :q! (exit sans save).
          t'es sous Unix?
          1. je crois qu'il parlai de shell, et il a stipulé qu'il ne voulais pas se servir d'éditeur de texte ...
          2. merci bien ....
        2. Salut,

          Pour generer du texte en script, tu peux utiliser

          echo "Alors qu\' il faisait beau"> NomFichier.txt
          Ceci va te creer un noveau fichier
          Mais si tu veux le remplir apres, il te faut tiliser la double redirection >>

          echo "J\'en allais me promener dans les champs"> NomFichier.txt


          Mais le mega outil por faire de l'edition puissante et rapide en script, c'est sed

          Et le meilleur tuto est sur ce site
          https://forums.commentcamarche.net/forum/affich-37620084-sed-introduction-a-sed-part-i

          Ex, si tu veux effacer la premiere ligne d'un texte
          sed '/1/,/1/ d' NomFichier.txt


          Un peu capilo-tracte a apprendre a debut a cause de l'adressage, mais alors apres....

          1. Copieur ! ^^
          2. Modérateur
            Salut,

            Ex, si tu veux effacer la premiere ligne d'un texte

            sed '/1/,/1/ d' NomFichier.txt


            Euh...non ;-(

            Là, tu demandes à effacer une ou plusieurs lignes comprises entre un motif représentant le chiffre UN et un autre motif représentant le chiffre UN ;-\

            sed '1d' fichier

            Suffit amplement.
        3. chose est sure c'est que tot ou tard tu doit mettre la main dans la patte, alors utilise sed ou vi (moi je préfère vi) malgré que sed est puissant aussi
          1. Exact jipicy !
            Autant pour moi, meme ma double redirection >> j'ai oublie de la coller dans le script, ouhhhhh.

            Bon, quoi qu'il en soit, sed est un superbe outil pour faire de l'edition de texte scriptee.
            On vois d'ailleurs le resultat lors des mesures des temps d'executions des scripts.

            sed est installe par defaut sur tous les UNIX, ce qui n'est pas le cas de python par exemple.
            1. Modérateur
              Salut,

              On vois d'ailleurs le resultat lors des mesures des temps d'executions des scripts.
              Si tu parles des scripts alors la durée de traitement n'est pas du totalement à sed mais aussi à la façon de conception (l'algo) de script.
              C'est pareil pour d'autre langage de script, awk, python, perl par exemple.
              Et puis il faut savoir ce qu'on doit faire, puisque sed et puissant mais limité par rapport à des langages de scripts, plus évolués.
              Ce qui est certe c'est que sed et un outil qui devrait se trouver dans la trousse à outils des amateurs de ligne de commande d'UNIX et GNU/Linux comme awk et vi d'ailleurs.
              Pour ne pas oublier grep ;-)

              sed est installe par defaut sur tous les UNIX, ce qui n'est pas le cas de python par exemple.

              Je ne connais pas les UNIX mais je pense que sur GNU/Linux, python est installé par défaut.
              Essaie un whereis python ou encore mieux essaie de désinstaller python et tu verras que ce qui peux se passer.

              Voici ce que ça donne sur un Debian. Le bureau Gnome par exemple partira dans les oubliettes.

              lami20j@debian:~$ whereis python
              python: /usr/bin/python2.5 /usr/bin/python /etc/python2.5 /etc/python /usr/lib/python2.5 /usr/lib/python2.4 /usr/local/lib/python2.5 /usr/include/python2.5 /usr/include/python2.4 /usr/share/python /usr/man/man1/python.1.gz /usr/share/man/man1/python.1.gz
              lami20j@debian:~$ sudo aptitude purge python
              [sudo] password for lami20j:
              Lecture des listes de paquets... Fait
              Construction de l'arbre des dépendances
              Lecture des informations d'état... Fait
              Lecture de l'information d'état étendu
              Initialisation de l'état des paquets... Fait
              Lecture des descriptions de tâches... Fait
              Les paquets suivants sont CASSÉS :
              alacarte alsa-utils deluge-torrent deluge-torrent-common deskbar-applet devhelp-common gconf2 gedit gnome-about gnome-app-install gnome-applets gnome-applets-data gnome-doc-utils gnome-games gnome-games-data gnome-menus
              grub-choose-default hal-cups-utils istanbul libpurple-bin lsb-release openssl-blacklist openvpn-blacklist python-4suite-xml python-apt python-cairo python-central python-cups python-cupsutils python-dbus python-eggtrayicon
              python-elementtree python-gdata python-gdbm python-glade2 python-gmenu python-gnome2 python-gnome2-desktop python-gnome2-extras python-gobject python-gst0.10 python-gtk2 python-gtkhtml2 python-gtkmozembed python-gtksourceview2
              python-libxml2 python-notify python-numeric python-openssl python-pyorbit python-sexy python-software-properties python-support python-svn python-tk python-vte python-xdg python-xlib reportbug rhythmbox serpentine
              software-properties-gtk svn-load system-config-printer totem-gstreamer totem-plugins unattended-upgrades update-manager update-manager-core update-notifier update-notifier-common
              Les paquets suivants seront ENLEVÉS :
              python{p}
              0 paquets mis à jour, 0 nouvellement installés, 1 à enlever et 0 non mis à jour.
              Il est nécessaire de télécharger 0o d'archives. Après dépaquetage, 627ko seront libérés.
              Les paquets suivants ont des dépendances non satisfaites :
              python-gst0.10: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              update-manager: Dépend: python (>= 2.4) mais il n'est pas installable
              python-gnome2: Dépend: python (>= 2.4) mais il n'est pas installable
              Dépend: python (< 2.6) mais il n'est pas installable
              python-support: Dépend: python (>= 2.4) mais il n'est pas installable
              hal-cups-utils: Dépend: python mais il n'est pas installable
              python-notify: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-software-properties: Dépend: python (>= 2.4) mais il n'est pas installable
              python-gnome2-extras: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              gnome-games: Dépend: python (>= 2.4) mais il n'est pas installable
              deluge-torrent: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              update-manager-core: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              totem-plugins: Dépend: python mais il n'est pas installable
              rhythmbox: Dépend: python mais il n'est pas installable
              python-gdata: Dépend: python mais il n'est pas installable
              alacarte: Dépend: python (>= 2.4) mais il n'est pas installable
              python-libxml2: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              gedit: Dépend: python mais il n'est pas installable
              gnome-menus: Dépend: python mais il n'est pas installable
              python-gtksourceview2: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              system-config-printer: Dépend: python (>= 2.4) mais il n'est pas installable
              python-numeric: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              reportbug: Dépend: python (>= 2.5) mais il n'est pas installable
              gconf2: Dépend: python mais il n'est pas installable
              openssl-blacklist: Dépend: python mais il n'est pas installable
              update-notifier-common: Dépend: python mais il n'est pas installable
              python-apt: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-pyorbit: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              update-notifier: Dépend: python mais il n'est pas installable
              deluge-torrent-common: Dépend: python (>= 2.4) mais il n'est pas installable
              python-gtkmozembed: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-gtkhtml2: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-openssl: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              devhelp-common: Dépend: python mais il n'est pas installable
              gnome-about: Dépend: python (>= 2.4) mais il n'est pas installable
              python-tk: Dépend: python (>= 2.4) mais il n'est pas installable
              Dépend: python (< 2.6) mais il n'est pas installable
              python-svn: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-glade2: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-eggtrayicon: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-sexy: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-xdg: Dépend: python (>= 2.3) mais il n'est pas installable
              grub-choose-default: Dépend: python mais il n'est pas installable
              svn-load: Dépend: python mais il n'est pas installable
              python-vte: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              unattended-upgrades: Dépend: python mais il n'est pas installable
              gnome-doc-utils: Dépend: python mais il n'est pas installable
              alsa-utils: Dépend: python mais il n'est pas installable
              python-central: Dépend: python (>= 2.4.3-10) mais il n'est pas installable
              python-dbus: Dépend: python (>= 2.4) mais il n'est pas installable
              Dépend: python (< 2.6) mais il n'est pas installable
              gnome-games-data: Dépend: python (>= 2.4) mais il n'est pas installable
              gnome-app-install: Dépend: python (>= 2.4) mais il n'est pas installable
              python-cupsutils: Dépend: python (>= 2.4) mais il n'est pas installable
              totem-gstreamer: Dépend: python mais il n'est pas installable
              software-properties-gtk: Dépend: python (>= 2.4) mais il n'est pas installable
              python-gdbm: Dépend: python (>= 2.4) mais il n'est pas installable
              Dépend: python (< 2.6) mais il n'est pas installable
              python-cups: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              libpurple-bin: Dépend: python mais il n'est pas installable
              python-4suite-xml: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              gnome-applets: Dépend: python (>= 2.4) mais il n'est pas installable
              python-gmenu: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-elementtree: Dépend: python (>= 2.3) mais il n'est pas installable
              python-xlib: Dépend: python mais il n'est pas installable
              deskbar-applet: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.5) mais il n'est pas installable
              python-gnome2-desktop: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              gnome-applets-data: Dépend: python (>= 2.4) mais il n'est pas installable
              istanbul: Dépend: python (>= 2.3) mais il n'est pas installable
              lsb-release: Dépend: python mais il n'est pas installable
              python-gtk2: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              python-cairo: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              openvpn-blacklist: Dépend: python mais il n'est pas installable
              serpentine: Dépend: python (>= 2.4) mais il n'est pas installable
              python-gobject: Dépend: python (< 2.6) mais il n'est pas installable
              Dépend: python (>= 2.4) mais il n'est pas installable
              Les actions suivantes permettront de résoudre ces dépendances :

              Supprimer les paquets suivants :
              alacarte
              alsa-utils
              anjuta
              bluez-gnome
              capplets-data
              cheese
              compiz-plugins
              cups
              cups-driver-gutenprint
              cupsys
              cupsys-driver-gutenprint
              deluge-torrent
              deluge-torrent-common
              deskbar-applet
              devhelp
              devhelp-common
              ekiga
              eog
              epiphany-browser
              epiphany-browser-data
              epiphany-extensions
              epiphany-gecko
              evince
              evolution
              evolution-data-server
              evolution-exchange
              evolution-plugins
              evolution-webcal
              fast-user-switch-applet
              file-roller
              gcalctool
              gconf-editor
              gconf2
              gdm
              gdm-themes
              gedit
              gksu
              gnome
              gnome-about
              gnome-app-install
              gnome-applets
              gnome-applets-data
              gnome-control-center
              gnome-core
              gnome-desktop-environment
              gnome-doc-utils
              gnome-games
              gnome-games-data
              gnome-keyring
              gnome-media
              gnome-media-common
              gnome-menus
              gnome-mount
              gnome-netstatus-applet
              gnome-network-admin
              gnome-panel
              gnome-panel-data
              gnome-power-manager
              gnome-screensaver
              gnome-session
              gnome-settings-daemon
              gnome-spell
              gnome-system-monitor
              gnome-system-tools
              gnome-terminal
              gnome-terminal-data
              gnome-user-guide
              gnome-utils
              gnome-vfs-obexftp
              gnome-volume-manager
              grace
              grip
              grub-choose-default
              gstreamer0.10-gnomevfs
              gstreamer0.10-plugins-good
              gthumb
              gtkhtml3.14
              gucharmap
              hal-cups-utils
              inkscape
              istanbul
              libbonoboui2-0
              libcamel1.2-11
              libdevhelp-1-0
              libebook1.2-9
              libecal1.2-7
              libedata-book1.2-2
              libedata-cal1.2-6
              libedataserverui1.2-8
              libeel2-2.20
              libexchange-storage1.2-3
              libgbf-1-1
              libgdl-1-0
              libgdl-gnome-1-0
              libgksu2-0
              libgnome-desktop-2
              libgnome-media0
              libgnome-window-settings1
              libgnome2-0
              libgnome2-common
              libgnome2-perl
              libgnome2-vfs-perl
              libgnomekbd-common
              libgnomekbd2
              libgnomekbdui2
              libgnomeui-0
              libgnomevfs2-0
              libgnomevfs2-bin
              libgnomevfs2-common
              libgnomevfs2-extra
              libgtkhtml3.14-19
              libgweather-common
              libgweather1
              libmetacity0
              libpanel-applet2-0
              libpurple-bin
              libslab0
              libtotem-plparser10
              liferea
              lsb-release
              mathwar
              metacity
              metacity-common
              nautilus
              nautilus-cd-burner
              nautilus-data
              network-manager-gnome
              network-manager-openvpn
              network-manager-openvpn-gnome
              notification-daemon
              openoffice.org-gnome
              openssl-blacklist
              openvpn
              openvpn-blacklist
              postfix
              python-4suite-xml
              python-apt
              python-cairo
              python-central
              python-cups
              python-cupsutils
              python-dbus
              python-eggtrayicon
              python-elementtree
              python-gdata
              python-gdbm
              python-glade2
              python-gmenu
              python-gnome2
              python-gnome2-desktop
              python-gnome2-extras
              python-gnupginterface
              python-gobject
              python-gst0.10
              python-gtk2
              python-gtkhtml2
              python-gtkmozembed
              python-gtksourceview2
              python-libxml2
              python-notify
              python-numeric
              python-openssl
              python-pyorbit
              python-sexy
              python-software-properties
              python-support
              python-svn
              python-tk
              python-vte
              python-xdg
              python-xlib
              reportbug
              rhythmbox
              seahorse
              serpentine
              software-properties-gtk
              sound-juicer
              ssl-cert
              sun-java6-plugin
              svn-load
              swfdec-gnome
              system-config-printer
              totem-common
              totem-gstreamer
              totem-mozilla
              totem-plugins
              tsclient
              unattended-upgrades
              update-manager
              update-manager-core
              update-notifier
              update-notifier-common
              vim-full
              vim-gnome
              vinagre
              vino
              xchat
              xchat-common
              xulrunner-1.9-gnome-support
              yelp

              Installer les paquets suivants :
              libnm-glib-vpn0 [0.7.2-2~bpo50+1 (lenny-backports)]
              libnm-util1 [0.7.2-2~bpo50+1 (lenny-backports)]
              notification-daemon-xfce [0.3.7-1 (stable)]
              xmail [1.25-4 (stable)]

              Mettre à jour les paquets suivants :
              network-manager-vpnc [0.6.4svn2806-1 (stable, now) -> 0.7.2-1~bpo50+1 (lenny-backports)]
              network-manager-vpnc-gnome [0.6.4svn2806-1 (stable, now) -> 0.7.2-1~bpo50+1 (lenny-backports)]

              Laisser les dépendances suivantes non satisfaites :
              alsa-base recommande alsa-utils
              apache2.2-common recommande ssl-cert
              compiz-core recommande compiz-plugins (= 0.7.6-7)
              cups-bsd recommande cups
              education-mathematics recommande grace
              education-mathematics recommande mathwar
              libeel2-data recommande libeel2-2.20
              evolution-common recommande evolution
              foomatic-filters-ppds recommande cups
              gedit-common recommande gedit
              libglib2.0-dev recommande python
              libgnome-keyring0 recommande gnome-keyring
              libpam-gnome-keyring recommande gnome-keyring
              libgtk2.0-dev recommande python (>= 2.4)
              installation-report recommande reportbug
              libnautilus-burn4 recommande gnome-mount (>= 0.4)
              network-manager recommande network-manager-gnome | network-manager-kde
              openoffice.org-evolution recommande evolution
              finch recommande gstreamer0.10-plugins-good
              libpurple0 recommande libpurple-bin
              python-minimal recommande python
              synaptic recommande gksu
              synaptic recommande libgnome2-perl
              acroread recommande gconf2
              Le score est de -53670

              Accepter cette solution ? [Y/n/q/?]