In Debian Linux we have one superb command tool called 'tr' [Translate or delete characters]. This simple handy tool has may usages, here am going to explain how to remove sequence of repeated (same)character.
The date command will produce output as follows
Ex-1-scenario:
$date
Thu Jun 2 17:10:17 IST 2011
Note: There are 2 spaces between the Month(Jun) and the date(2) because the date is single digit.
Ex-2-scenario:
$date
Thu Jun 22 17:10:17 IST 2011
So, if i try to cut the date using cut command then with empty space( ) as delimiter. then the field count will change.
For example:
Ex-1-scenario:
In f1-Thu f2-Jun f3-( ) f4-2 f5-17:10:17 f6-IST f7-2011
Ex-2-scenario:
In f1-Thu f2-Jun f3-2 f4-17:10:17 f5-IST f6-2011
So, how can i split fields correctly regardless of the single or double digit dates. Here comes our tr tool. It will be done as follows
for both scenario-1, scenario-2
$date | tr -s ' '
Note: if you use tr -s 'y' it will remove the continues occarance of 'yyyyy' and put only one single 'y' there.
will output with single space( ) between fields. Happy scripting.. :)
For more information see the man page of tr, date commands. For online man pages of tr, date.
A Blog for technical Linux, shell, php, mysql, python, OpenSource | Career | Books | Movies
Customized search within this blog
Thursday, June 2, 2011
Thursday, May 26, 2011
How to access a directory as root/Super user in Linux?
In debian Linux if you are logged in as a ordinary(lower previleged user), then you cant access all the directories in the filesystem. Becayse if tge security restrictions. So, if you want to access a particular directory which needs the higher privelege(say /root) you have 2 choices.
1. By Terminal
Just open the terminal by
1) Applications -> Accessories -> Terminal
or
2) alt + f2 -> type "gnome-terminal"(witout quotes) & hit enter key
Now change yourself as root by issuing the command $su root & corresponding Password and access the directory what you want.
2. By GUI(using Nautilus)
Right click the directory which you want to access as super/root user. Then select the option "open as administrator".
Now it prompts you for the Admin(Root) password then it open that directory as a root user. so, now you can access all the files with read,write, execute permission.
Note: For getting the option "open as administrator" your system must installed the package "nautilus-gksu". If not install it first with the following command '$sudo apt-get install nautilus-gksu'(use without quotes,dollar symbol)
Note:(Am using BOSS Linux - a famous indian distro based on Debian developed by CDAC).
1. By Terminal
Just open the terminal by
1) Applications -> Accessories -> Terminal
or
2) alt + f2 -> type "gnome-terminal"(witout quotes) & hit enter key
Now change yourself as root by issuing the command $su root & corresponding Password and access the directory what you want.
2. By GUI(using Nautilus)
Right click the directory which you want to access as super/root user. Then select the option "open as administrator".
Now it prompts you for the Admin(Root) password then it open that directory as a root user. so, now you can access all the files with read,write, execute permission.
Note: For getting the option "open as administrator" your system must installed the package "nautilus-gksu". If not install it first with the following command '$sudo apt-get install nautilus-gksu'(use without quotes,dollar symbol)
Note:(Am using BOSS Linux - a famous indian distro based on Debian developed by CDAC).
Thursday, May 19, 2011
Want to see What happens during system bootup(Linux) & startup services/scripts
1. While booting the system boot it in single user mode.
i.e press ctrl+alt+f1 <- if you have any problem to see the terminal(No GUI splash image) with messages and informations do the following
Note:
In BOSS linux one can see the background startup services and their messages by pressing the F2 key
during startup of the system(i.e during the 'Splash image with boss logo' loaded)
2. While booting select the OS, in which you want to login using up/down arrow now press 'e'. It leads you to the grub menu and now you can edit the
booting options. So now we want to see the messages from the startup services for that just remove the phrase 'splash VGA=xyz quiet'. Then press "ctrl+x" to boot the system. By doing this we are just denying the splash image to load. So we can see the startup services and their messages.
Note: If the messages runs fast and moves in a flash, then just add 'sleep 50' in the startup script (those scripts in /etc/init.d/*) which you want to monitor.
Monday, March 28, 2011
Compiz 2 Desktop(instead of 4) problem... How to fix it?
Compiz is one of the superb package(window manager) that gives a nice 3d look and feel even apple's OS can't be compete with it.
Most of the new users who installed the Compiz got the problem of getting only 2 desktops instead of default 4. So, how could we fix it..
1. After installing the Compiz one got the menu entry in Systemtools.
so, Applications - > System tools - > Compiz fusion icon
If we click the that a new icon will be placed in the panel.
2. Now right click on that icon, we get a pop up options like.. compiz options, reload window manager, etc... find the settings manager and click on that.
3. Now we get compiz Configuration setting manager, in that select general tab. Then select General options.
4. In general Options select the Desktop size. In that there will be a slider with the name "Horizontal Virtual Size" with the value 2. Change it to the value (4) you wish(number of desktops). That's it.
The real thing you can create as much desktop as you wish..
Enjoy & experience the linux...
Note: Am using BOSS GNU/Linux.. (Debian derived) An Indian Linux Distro. for more info http://bosslinux.in/ http://wiki.bosslinux.in/
Want to read more about compiz. Refer wikipedia in this link http://en.wikipedia.org/wiki/Compiz
Friday, March 25, 2011
How to convert .ogv file into .mp4 file
1. Download the Handbrake-CLI software package from the following site. http://handbrake.fr/
2. Install the deb using the following command. $sudo dpkg -i
3. Now you got the command 'HandBrakeCLI'. now issued the command as follows
$HandBrakeCLI -i -o
thats all.
2. Install the deb using the following command. $sudo dpkg -i
3. Now you got the command 'HandBrakeCLI'. now issued the command as follows
$HandBrakeCLI -i
thats all.
Subscribe to:
Posts (Atom)