Tag Archives: howto

Quick Tutorial – How to zip and unzip files under unix environment


Linux support zip and unzip facility.
All you need to install zip and unzip via apt-get in your debian/ubuntu linux.
The same is available via yum or zypper.

Some examples for zip and unzip.

1. Creates the zip archive and put all the files of the current directory in the compressed form.

ankur@ankur:~> cd test/
ankur@ankur:~/test> ll
total 0
-rw-r--r-- 1 ankur users 0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users 0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users 0 2010-10-20 10:03 3.txt
ankur@ankur:~/test> zip zipthis *
 adding: 1.txt (stored 0%)
 adding: 2.txt (stored 0%)
 adding: 3.txt (stored 0%)
ankur@ankur:~/test> ll
total 4
-rw-r--r-- 1 ankur users   0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users   0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users   0 2010-10-20 10:03 3.txt
-rw-r--r-- 1 ankur users 382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test>

This command will automatically put the zip extension when the process will done.

2. Now try for zipping the subdirectory also..
Here I have created the subdirector as “subtest”.

ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
drwxr-xr-x 2 ankur users 4096 2010-10-20 10:14 subtest
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test> zip -r subzipthis *
 adding: 1.txt (stored 0%)
 adding: 2.txt (stored 0%)
 adding: 3.txt (stored 0%)
 adding: subtest/ (stored 0%)
 adding: subtest/sub1.txt (stored 0%)
 adding: subtest/sub2.txt (stored 0%)
 adding: zipthis.zip (stored 0%)
ankur@ankur:~/test> ll
total 12
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
drwxr-xr-x 2 ankur users 4096 2010-10-20 10:14 subtest
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test>

To use unzip to extract all files of the archive pics.zip into the current directory & subdirectories:

3. Listing of your files from a zip folder.

ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip
ankur@ankur:~/test> unzip -l subzipthis.zip
Archive:  subzipthis.zip
 Length     Date   Time    Name
 --------    ----   ----    ----
 0  10-20-10 10:03   1.txt
 0  10-20-10 10:03   2.txt
 0  10-20-10 10:03   3.txt
 0  10-20-10 10:14   subtest/
 0  10-20-10 10:14   subtest/sub1.txt
 0  10-20-10 10:14   subtest/sub2.txt
 382  10-20-10 10:05   zipthis.zip
 --------                   -------
 382                   7 files
ankur@ankur:~/test>

4. To test about your zip archive that archive is OK or not:

ankur@ankur:~/test> unzip -tq subzipthis.zip
No errors detected in compressed data of subzipthis.zip.
ankur@ankur:~/test> unzip -tq zipthis.zip
No errors detected in compressed data of zipthis.zip.

5. Unzip your data

ankur@ankur:~/test> unzip zipthis.zip
Archive:  zipthis.zip
 extracting: 1.txt
 extracting: 2.txt
 extracting: 3.txt
ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

6. Now you want to extract only the specific files from your zip folder. You can use like this…

ankur@ankur:~/test> unzip zipthis.zip 1.txt
Archive:  zipthis.zip
 extracting: 1.txt
ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

7. To extract all files to some specified directory.

ankur@ankur:~/test> unzip zipthis.zip -d /home/ankur/test/
Archive:  zipthis.zip
 extracting: /home/ankur/test/1.txt
 extracting: /home/ankur/test/2.txt
 extracting: /home/ankur/test/3.txt
ankur@ankur:~/test> ll
total 8
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

8. Unzip files one by one with confirmation.

ankur@ankur:~/test> unzip -q subzipthis.zip
replace 1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
replace 2.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
replace 3.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
replace zipthis.zip? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
ankur@ankur:~/test> ll
total 12
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 1.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 2.txt
-rw-r--r-- 1 ankur users    0 2010-10-20 10:03 3.txt
drwxr-xr-x 2 ankur users 4096 2010-10-20 10:14 subtest
-rw-r--r-- 1 ankur users 1306 2010-10-20 10:15 subzipthis.zip
-rw-r--r-- 1 ankur users  382 2010-10-20 10:05 zipthis.zip

9. Zip and Unzip version and liceance.

zip -v
zip -L
unzip -v

10. Help from zip and unzip

zip -h
unzip -h

install tweetdeck on ubuntu 10.04


I usually use twitter and facebook from web only. Today i thought to use some client. I found TweetDeck. I thought it must be awesome. So I installed it.

Its very easy to install on Ubuntu 10.4 thanks to TweekDeck and Ubuntu Team.

TweetDeck – http://www.tweetdeck.com/desktop/

It goes like this

  • Download Adobe AIR from http://labs.adobe.com/downloads/air_linux.html
  • Get the .deb file from above page.
  • Use dpkg -i .deb file and this will automatically install Adobe AIR in your computer.
    ganu@ganu:~$ sudo dpkg -i /tmp/adobeair.deb
    Selecting previously deselected package adobeair.
    (Reading database ... 219838 files and directories currently installed.)
    Unpacking adobeair (from /tmp/adobeair.deb) ...
    Setting up adobeair (2.0.3.13070) ...
    
  • Download TweetDeck AIR from from there website or from direct link at http://www.tweetdeck.com/beta/TweetDeck_0_35.1.air
  • You can also directly download the latest air file from TweetDeck website page. It will download the latest version.
  • Run the air file, double click it and follow the instructions.
  • Yea its done.

Attached are some photos.



Happy Social Networking. 😛

Start working with symfony 1.4


My colleague Subedar has started using Symfony 1.4. Today he shared me this list that how to install symfony 1.4 into your machine.

This is tested in windows, I have not tried in my ubuntu lappy. I will try and setup in my linux lappy and buzz you will more updates. I have some idea with 1.4 let see… Stay tuned…

Step for symfony 1.4 installation

  1. create a folder for your project on your local machine
    Ex project name  “testproject”
  2. Create “lib” folder in  project folder and create “vendor” in lib folder
    now the directory structure become  projectname/lib/vendor
  3. Now put symfony1.4 file in vendor folder and rename it as symfony
  4. Now execute the following command
    if  you want project with propel then execute

    php lib\vendor\symfony\data\bin\symfony generate:project testproject --orm=Propel

    if you want project in doctrine

    php lib\vendor\symfony\data\bin\symfony generate:project testproject --orm=none
  5. Now set database and password
    php symfony configure:database "mysql:host=localhost;dbname=dbname"  root rootPassword
  6. you can directly change in the file database.yml and propel.ini
  7. Now create application by executing
    php symfony generate:app frontend
  8. Create module
    php symfony generate:module frontend default
  9. Check php.ini if extension=php_pdo.dll not open then open it also check extension=php_pdo_mysql.dll

Hope this will be helpfull. Happy Programming.