Cat is one of the most well know commands of the Linux as well as of Unix systems. It’s mainly use to display the file contents of a small file on the terminal. But scope of the cat commands is not just limited to display, We can use the cat command to create,append and even in the concatenation of the two files. In this post we will learn how to complete these jobs using the same cat command.
Display : As stated above we mostly use cat utility for the display purpose only. To display a file using cat use the following syntax without brackets “cat filename1 filename2…” . You can display single file as well as multiple files in one go. In case of multiple files, file2 will get display after the file1. Example – In the screenshot below we are displaying the contents of the test file using cat command.
Display Using Cat
You can use options like ‘-v’ , ‘-n’ etc to enrich the display. Look at the man pages for the options by typing man cat.
Create : This is the best part about cat. You can even create your text files using this utility. Enter the cat command followed by the redirect output ‘>’ character and the filename. In short, something like this “cat > file” . When you press enter the prompt vanishes. cat now waits to take the input from the user. Enter your text. Press [Ctrl-d] to signify the end of file character.The system will understand that no further text input will be made. The file is written and the prompt is returned. To verify you can use the cat file again.
Append : We can append a file by using append character “>>” utility along with the cat command. Syntax for appending is “cat >> file”. In this cat waits for the user to enter the input on to the terminal and then reads it. After reading it appends it into the file.
Append Your Files
Concatenate : Sometimes you need to concatenate two files especially if you are following the modular coding techniques. You can easily concatenate two files by using the redirecting output parameter ‘>’. We can concatenate two files into the third file by following a syntax like “cat file1 file2 >file3” . It will first write down the file1 and then file2 into the file3.
Scope of cat is not just limited to only these four functions. You can learn more about this utility using the web or by reading the man pages.
Have you accidentally deleted an important file because you are in a habit of using “Shift+Del” rather than delete only?? Well don’t panic. There is a utility named as “scalpel” which helps you in recovering the so called “permanent deleted” files. Actually when you delete a file permanently (Accidentally or By Intention) , It doesn’t get removed from your hard disk. It get stored in certain blocks of the storage device and they continue to exist in the blocks unless you overwrite them with another files. This article will talk about utilities that will help you in the file recovery. It is always recommended that you shouldn’t recover a file from the device when it is mounted. You should always do the recovery process with the Live CD followed by the file searching in the device like in my case device is /dev/sda1 . If you are unable to understand the upper condition, just forget about it. I am not going to bore you with the theory part anymore. Let’s take a look at the utility.
Scalpel is a file system independent recovery tool. It ‘s basically available for the Linux and Mac OS but you can also run it on windows by compiling it using the mingw. Latest version of scalpel is 2.0 . You can install it in Ubuntu by typing sudo apt-get install scalpel. After installing it you need to do some text editing. Scalpel utility has its configuration file in the /etc directory with full path as /etc/scalpel/scalpel.conf . When viewed (using gedit/nano/cat) you will notice that everything is a comment out there. Uncomment the file format which you want to recover. For example in my case I want to recover the .zip file so I will uncomment the .zip file section in the scalpel.conf file just like below.
After that go to the terminal and follow the syntax :
sudo scalpel <device name/Directory name/file name> -o <ouput directory>
Output directory is the directory where you want to restore your deleted files. It should be empty before running the command, otherwise you will get an error. You can also input the deleted filename directly by using -i option.You can see the screenshot of my device search below .
Although utilities are there to recover your file but I would recommend you guys to put a habit of delete only not of “Shift+Del” because prevention is always better than cure :D
Few days back I released my game named as “Hungry Snake” on Google Code http://code.google.com/p/hungry-snakes/ . Today I got an email from the Softpedia team that they have added my game under the category of Mac Os applications Category. They tested the game in their software labs and certified it as 100 % free which means it does not contain any form of malware, including but not limited to: spyware, viruses, trojans and backdoors. The Game is published under the GPL license. You can run it on any platform. At the time of the writing download count in total (Google Code + Softpedia) is about 250. I can feel the power of open source. Thanks to Richard Stallman and Linus Torvalds .
Game Download Links – http://code.google.com/p/hungry-snakes/downloads/list
Softpedia Certificate Link – http://mac.softpedia.com/progClean/Hungry-Snake-Clean-98721.html
Its been almost a week from the release of the Ubuntu 11.04 “Natty Narwhal“. I got mixed reviews about this version from other blogs. I haven’t tried it yet because I am in love with the 10.04 Desktop Edition and believes that there is no need to switch right now. For the Geeks who are running Ubuntu 11.04 on their machines and are struggling with the shortcuts, below is the Wallpaper (Cheat Sheet) for you. Save it and learn them🙂
Natty Narwhal Shortcuts Wallpaper