
Foto mit freundlicher Genehmigung von gfpeck
Zuvor haben wir 15 praktische Beispiele für die Befehle find und grep besprochen. Jetzt ist es an der Zeit, unsere Aufmerksamkeit auf etwas weniger zu richten.
In diesem Artikel sehen wir uns an, wie der Linux-Leser-Befehl zum Öffnen und Anzeigen verwendet werden kann die folgenden 10 verschiedenen Dateitypen :
- PDF-Datei – *.pdf
- Word-Dokument – *.doc
- Bilddateien – *.gif, *.jpg, *.jpeg, *.png
- TAR-Dateien – *.tar
- TAR-Dateien mit gzip – *.tar.gz
- Zip-Dateien – *.zip
- Gzip- und Gzip2-Dateien – *.gz und *.bz2
- ISO-Dateien
- Debian-Dateien – *.deb
- RPM-Dateien – *.rpm
Setzen Sie die Umgebungsvariable LESSOPEN auf lesspipe
Stellen Sie zunächst sicher, dass in der Umgebungsvariable Folgendes festgelegt ist.
$ set | grep less LESSOPEN='|/usr/bin/lesspipe.sh %s'
Bitte beachten Sie, dass Sie auch Folgendes tun können, um die Lesspipe einzurichten.
$ eval "($lesspipe)" $ cat ~/.bashrc eval "($lesspipe)"
- lesspipe , lessfile sind der Input-Präprozessor für weniger, der es ermöglicht, alle Arten von Dateien zu öffnen.
- lesspipe ermöglicht es Ihnen, während des Konvertierungsprozesses mit Pipe zu öffnen.
- lessfile schließt zuerst die Konvertierung ab und zeigt dann den Inhalt an. Dies schreibt das konvertierte Ding in eine temporäre Datei und zeigt es dann an.
- Sie können auch Ihren eigenen Eingabe-Präprozessor schreiben und verwenden.
Dateityp 1:Wie öffne ich eine PDF-Datei?
Es zeigt den gesamten Text in der PDF-Datei deutlich an, ignoriert jedoch die Bilder. Die Ausgabe kann hier und da einige Sonderzeichen enthalten. Aber es ist auf jeden Fall lesbar.
$ less Linux-101-Hacks.pdf ^LLinux 101 Hacks www.thegeekstuff.com o o o Chapter 1: Powerful CD Command Hacks cd is one of the most frequently used commands during a UNIX session. The cd command hacks mentioned in this chapter will boost your productivity
Dateityp 2:Wie öffne ich eine Word-Dokumentdatei?
$ less pdb.doc The Python Debugger Pdb ======================= To use the debugger in its simplest form: >>> import pdb >>> pdb.run The debugger's prompt is Pdb. This will stop in the first function call in
Dateityp 3:Wie öffne ich eine JPG-, JPEG- oder PNG-Datei?
Beim Öffnen einer Bilddatei (jpeg, jpg und png) zeigt der Befehl less die folgenden Informationen:
- Name der Datei
- Dateityp
- Anzahl Pixel – Breite und Höhe
- Größe der Datei
$ less testfile.jpeg testfile.jpeg JPEG 2304x1728 2304x1728+0+0 DirectClass 8-bit 1.57222mb 0.550u 0:02
Hinweis: Ähnliche Informationen werden für andere Bilddateitypen angezeigt.
Dateityp 4:Wie öffne ich eine archivierte Datei (z. B. *.tar) ?
Beim Öffnen der Archivdatei wird „ls -l“ der im Archiv verfügbaren Dateien angezeigt, sodass Sie die Größe der Datei, die Berechtigungen und den Eigentümer sowie die Gruppe sehen können.
$ less autocorrect.tar -rwxrwxrwx anthony/anthony 84149 2009-02-02 03:20 autocorrect.dat -rwxrwxrwx anthony/anthony 443 2009-02-02 03:21 generator.rb -rwxrwxrwx anthony/anthony 181712 2009-02-02 03:21 autocorrect.vim
Dateityp 5:Wie öffne ich eine archivierte, komprimierte Datei im gzip-Format (d. h. *.tar.gz-Format)?
Für die archivierte und komprimierte Datei zeigt auch der Less-Befehl die Ausgabe im „ls -l“-Format an.
$ less XML-Parser-2.36.tar.gz drwxr-xr-x matt/matt 0 2007-11-20 19:58 XML-Parser-2.36/ -rw-r--r-- matt/matt 25252 2007-11-20 19:52 XML-Parser-2.36/Changes drwxr-xr-x matt/matt 0 2007-11-20 19:58 XML-Parser-2.36/Expat/ -rw-r--r-- matt/matt 3184 2003-07-27 16:37 XML-Parser-2.36/Expat/encoding.h -rw-r--r-- matt/matt 33917 2007-11-20 19:54 XML-Parser-2.36/Expat/Expat.pm -rw-r--r-- matt/matt 45555 2007-11-17 01:54 XML-Parser-2.36/Expat/Expat.xs
Dateityp 6:Wie öffne ich eine archivierte und komprimierte Datei im Zip-Format (d. h. *.zip-Format)?
Es zeigt die Details der archivierten und komprimierten Datei im folgenden Format.
Archive: Archive name Length Method Size Ratio Date Time CRC-32 Name -------- ------ ------- ----- ---- ---- ------ ----
$ less bash-support.zip Archive: bash-support.zip Length Method Size Ratio Date Time CRC-32 Name -------- ------ ------- ----- ---- ---- ------ ---- 0 Stored 0 0% 01-30-09 19:56 00000000 ftplugin/ 13488 Defl:N 2167 84% 01-30-09 19:53 b1bc6f3c ftplugin/sh.vim 5567 Defl:N 1880 66% 01-30-09 02:16 0017a875 README.bashsupport 0 Stored 0 0% 01-30-09 19:56 00000000 doc/ 41013 Defl:N 11574 72% 01-30-09 19:50 0cc22a14 doc/bashsupport.txt 0 Stored 0 0% 01-30-09 19:56 00000000 bash-support/ 0 Stored 0 0% 01-30-09 19:56 00000000 bash-support/templates/ 513 Defl:N 187 64% 11-16-07 23:06 580ee37c bash-support/templates/bash-file-header 246 Defl:N 80 68% 01-31-07 21:51 54706588 bash-support/templates/bash-function-description 175 Defl:N 23 87% 01-31-07 21:51 22db9b2d bash-support/templates/bash-frame 0 Stored 0 0% 01-30-09 19:56 00000000 bash-support/rc/ 6545 Defl:N 1807 72% 06-17-07 14:01 e7a27099 bash-support/rc/customization.vimrc 2144 Defl:N 526 76% 01-31-07 21:51 f3a5e8dd bash-support/rc/customization.gvimrc
Dateityp 7:So öffnen Sie eine komprimierte Datei gzip &bzip2.
Zeigt den Inhalt der komprimierten Datei an. Wenn die Datei nur komprimiert und nicht archiviert ist, wird der Inhalt der Datei angezeigt. Es zeigt jedoch nicht den Inhalt eines ZIP-Dateiformats, sondern nur die Informationen in dem in Dateityp 7 erläuterten Format.
Dateityp 8:Wie öffne ich eine ISO-Datei?
Beim Öffnen einer ISO-Datei werden Informationen über die ISO-Datei und dann der Inhalt der Datei angezeigt.
$ less knoppix_5.1.1.iso CD-ROM is in ISO 9660 format System id: LINUX Volume id: KNOPPIX Volume set id: Publisher id: KNOPPER.NET Data preparer id: www.knopper.net Application id: KNOPPIX LIVE LINUX CD Copyright File id: Abstract File id: Bibliographic File id: Volume set size is: 1 Volume set sequence number is: 1 Logical block size is: 2048 Volume size is: 356532 El Torito VD version 1 found, boot catalog is in sector 763 Joliet with UCS level 3 found Rock Ridge signatures version 1 found Eltorito validation header: Hid 1 Arch 0 (x86) ID 'KNOPPER.NET' Key 55 AA Eltorito defaultboot header: Bootid 88 (bootable) Boot media 0 (No Emulation Boot) Load segment 0 Sys type 0 Nsect 4 Bootoff 312 786 /KNOPPIX /autorun.bat /autorun.inf /autorun.pif /boot /cdrom.ico /index.html /KNOPPIX/KNOPPIX /KNOPPIX/KNOPPIX-FAQ-EN.txt
Dateityp 9:Wie öffne ich eine deb-Datei?
Wenn Sie eine Debian-Datei öffnen, zeigt sie die Informationen über dieses Paket und auch das „ls -l“ der in diesem Paket verfügbaren Dateien, wie unten gezeigt.
$ less lshw_02.08.01-1_i386.deb lshw_02.08.01-1_i386.deb: new debian package, version 2.0. size 295134 bytes: control archive= 730 bytes. 678 bytes, 16 lines control 246 bytes, 4 lines md5sums Package: lshw Version: 02.08.01-1 Section: utils Priority: optional Architecture: i386 Depends: libc6 (>= 2.3.6-6), libgcc1 (>= 1:4.1.0), libstdc++6 (>= 4.1.0), lshw-common Installed-Size: 716 Maintainer: Ghe Rivero Description: information about hardware configuration A small tool to provide detailed information on the hardware configuration of the machine. It can report exact memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed, etc. on DMI-capable x86 systems, on some PowerPC machines (PowerMac G4 is known to work) and AMD64. . Information can be output in plain text, HTML or XML. *** Contents: drwxr-xr-x root/root 0 2006-08-10 04:15 ./ drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/ drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/bin/ -rwxr-xr-x root/root 665052 2006-08-10 04:15 ./usr/bin/lshw drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/share/ drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/share/man/ drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/share/man/man1/ -rw-r--r-- root/root 1874 2006-08-10 04:15 ./usr/share/man/man1/lshw.1.gz drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/share/lshw/ drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/share/doc/ drwxr-xr-x root/root 0 2006-08-10 04:15 ./usr/share/doc/lshw/ -rw-r--r-- root/root 999 2006-08-10 04:13 ./usr/share/doc/lshw/copyright -rw-r--r-- root/root 1386 2006-08-10 04:13 ./usr/share/doc/lshw/changelog.Debian.gz
Dateityp 10:Wie öffne ich eine RPM-Datei?
Der Befehl less kann die Details des RPM-Pakets und seines Inhalts anzeigen.
$ less openssl-devel-0.9.7a-43.16.i386.rpm openssl-devel-0.9.7a-43.16.i386.rpm: Name : openssl-devel Relocations: (not relocatable) Version : 0.9.7a Vendor: Scientific Linux , http://www.scientificlinux.org Release : 43.16 Build Date: Thu May 3 12:18:00 2007 Install Date: (not installed) Build Host: lxcert-i386.cern.ch Group : Development/Libraries Source RPM: openssl-0.9.7a-43.16.src.rpm Size : 3845246 License: BSDish Signature : DSA/SHA1, Wed May 9 15:03:20 2007, Key ID 5e03fde51d1e034b Packager : Jaroslaw Polok URL : http://www.openssl.org/ Summary : Files for development of applications which will use OpenSSL. Description : OpenSSL is a toolkit for supporting cryptography. The openssl-devel package contains static libraries and include files needed to develop applications which support various cryptographic algorithms and protocols. *** Contents: /usr/include/openssl /usr/include/openssl/aes.h /usr/include/openssl/asn1.h /usr/include/openssl/asn1_mac.h /usr/include/openssl/asn1t.h /usr/include/openssl/bio.h /usr/include/openssl/blowfish.h /usr/include/openssl/bn.h /usr/include/openssl/buffer.h /usr/include/openssl/cast.h /usr/include/openssl/comp.h /usr/include/openssl/conf.h /usr/include/openssl/conf_api.h
Dieser Artikel wurde von SathiyaMoorthy, Autor von , verfasst 15 Praktische Beispiele für Linux-Suchbefehle Artikel. The Geek Stuff freut sich über Ihre Tipps und Gastartikel