Wednesday, August 20, 2008

Tips & Tricks : How to list contents ? on Linux/Unix or On Windows

It always happens that we would like to see what is inside that folder or inside that archive. No matter what type of contents are there, it is necessary to get it through listing those directories and archives.

So here are some handy tips, I use for my daily work:

  • Directory listing on Linux and Windows

  • Ever wonder how to see all the subfolders under main parent folder. Here is the trick to list all files and folders recursively.

    • This is on Linux/Unix

    • ls -R -1

    • This is on Windows

    • dir /s /b

  • Listing contents of archive files

  • On Linux/Unix and Windows, lots of time, in day's work it happens that we come across JAR, TAR, GZ,BZIP, RAR etc archive formats and before opening those FTPed or SCPed or magically appeared archives we do like to see if those are right archives.

    So here are some tips on that:

    • Listing tar file contents

    • tar -tvf tararchive.tar

    • Listing tar.gz file contents

    • tar -ztvf gzippedtararchive.tar.gz

    • Listing the contents of a tar.bz2 archive

    • tar -jtvf file.tar.bz2

    • Listing the contents of a Java archive (JAR,WAR,EAR etc)

    • jar tvf jararchive.jar

    • Listing contents of ZIP Archive. Assuming unzip is been installed on the linux box.

    • unzip -l zippedarchive.zip

    • Listing contents of RAR archive. Assuming unrar is been installed on the linux box.

    • unrar l rararchive.rar

    • Listing contents of GZIP or GUNZIP or GZCAT or ZCAT archive. Assuming either of these commands are installed on Linux box.

      gzip -l gziparchive.gz

      gunzip -l gunziparchive.gz

      zcat -l zcatarchive.Z

Please let me know if you have any such tricks to share with our readers. Feel free to put it in comments.


No comments: