Archive for January, 2013

Linux tar, gz and bz2

January 17th, 2013 No comments
  • t: List the contents of an archive
  • v: Verbosely list files processed (display detailed information)
  • z: Filter the archive through gzip so that we can open compressed (decompress) .gz tar file
  • j: Filter archive through bzip2, use to decompress .bz2 files.
  • f: File. Use the tar file argument as the name of the tar file
  • x: Extract or restore
  • c: Create


tar -tvf file.tar : list the contents of the tar file 
tar -xvwf myfile.tar : extract all files from the tar 
tar xvf test.tar testfile1.bz2 : extract only the file called testfile1.bz2 from a tar archive
tar -cvwf txtfiles.tar *.txt : create a tar of all .txt files, name the tar file txtfiles.tar and put it in the current dir

bz2 ( bunzip2 )

tar -jtvf file.tar.bz2 : list the contents of the tar.bz2 file
tar -xvjpf filename.tar.bz2 : unzip a file compressed with .tar.bz2 
bzip2 filename.txt : compress a file with bunzip2 
bunzip2 filename.bz2 : unzip a file compressed only with bz2

gzip ( gunzip )

tar -ztvf file.tar.gz : list the contents of the tar.gz file
gzip filename.txt : compress a file using gunzip
gunzip filename.txt.gz : uncompress a file using gunzip
Categories: Linux Tags:

Linux Add date to file names

January 11th, 2013 No comments

Sometimes when you are running cron jobs and creating log files, you need a way to add date and time-stamps to the files names. Here is something you can try – I am adding timestamps to the file names below

mkdir test
cd test
echo "file-1" > log-file-$(date +%s).log  
echo "file-2" > $(date +%s)-log-file.log
ls -la

%s gives the timestamp

To see all the date formats refer to this excellent article:

Categories: Linux, Tips and Tricks Tags:

Windows 7 search files using dates

January 9th, 2013 No comments
  1. Just go to the search bar inside the folder you want to search
  2. When you click on the search bar, you might see some suggestions like Date Modified – click on that
  3. Else type datemodified:  hit enter and a box must pop up – see pictures below
  4. Choose your option
  5. If you want to do a range search, then all you need to do is click, hold and drag your mouse across dates ( like is pic 2 )
  6. If you want to search using both date and size, you can combine the two
  7. just use a semicolon
  8. So if i want to search by both date and size, in the search bar, i would type datemodified: hit enter and select the date(s)
  9. Then add a semicolon at the end and enter size:  and select the size ( see pic 3 )


Categories: Tips and Tricks Tags: