How to Use the alias Command
Let us say you execute the command ‘ls –alh’ every time you need a long listing of files and directories. Now you want a shortcut to do this. Fortunately, you can do so by using the command alias.
The alias command is useful for creating shortcuts for long commands or for correcting typing mistakes.
To create a shortcut for ls, you can do this:
$ alias ls=”ls -alh”
Now, everytime you execute ls command, it will be run as if you are executing the whole ls –alh command. Be reminded that this will replace the existing ls command. You may use a different name for the new shortcut like so:
$ alias ll=”ls -alh”
However, once you exit the current terminal, the alias will not be saved. To make the alias permanent, you may edit the .bashrc file in user’s home directory:
$ vi ~rai/.bashrc
Then insert the alias command after the line that says #system wide functions and aliases. Save and exit.
That should do it!
Using Perl to Replace Text in Multiple Files
You can search and replace text inside multiple files using Perl. This is how you do it:
$ perl -i -pe 's/Windows/Linux/;' test*
This command will search for the word ‘Windows’ inside all files that begin with ‘test’. When it finds one, it will substitute it with the word ‘Linux’. This is useful if you have multiple files that contain the same text. Remember that you can use regular expressions to make searching flexible.
Fix Fatal error: Allowed memory size of 8388608 bytes exhausted
I was installing xdebug a few days back to one of the production servers when I encountered this beautiful error message:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 143 bytes) in /usr/share/pear/PEAR/PackageFile/v2/Validator.php on line 1608 Allowed memory size of 8388608 bytes exhausted (tried to allocate 64 bytes)
So my instinct tells me to look inside the php.ini file and find for this line:
memory_limit = 12M
The server’s php.ini file is already set to 256M so I should go look for something else. Luckily, I found this tip from www.agileapproach.com.
Open the file /usr/share/pear/pearcmd.php and add this right after the < ?php line:
@ini_set('memory_limit', '16M');
That should fix the “Fatal error: Allowed memory size” error. I can now resume installing xdebug without any errors.
The reason why editing the php.ini will not fix the issue is because PECL/PEAR does not use the PHP settings, so the PEAR settings needs to be adjusted.
Hope this helps.
Tip: Remove Duplicate Lines in File Using Perl
Here is little nifty code I found to snip or remove duplicate lines in a file using Perl. An example of a file that has duplicate lines looks like this:
/home/index.php
/home/links.php
/home/index.php
The result we want to achieve is this:
/home/index.php
/home/links.php
And here goes the code:
$ftmp = 'file.txt';
my %match = ();
{
local @ARGV = ($ftmp);
local $^I = '.tmp';
while(<>){
$match{$_}++;
next if $match{$_} > 1;
print;
}
}
The original file, file.txt, has its duplicate lines removed.
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- david portman
on Cebu Pacific Airlines is Evil! - kim chiu
on Cebu Pacific Airlines is Evil! - Alma
on Cebu Pacific Airlines is Evil! - AnnKatz
on Cebu Pacific Sucks - chinito
on Cebu Pacific Airlines is Evil!








