How to echo a tab in bash?
Answer:
In Bash script, if you want to print out unprintable characters such as tab, you need to use -e flag together with the echo command.
E.g.
echo -e "\tfoo\tbar"
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to echo a tab in bash?
Answer:
In Bash script, if you want to print out unprintable characters such as tab, you need to use -e flag together with the echo command.
E.g.
echo -e "\tfoo\tbar"
How to modify a single character in a string in Python?
Answer:
Strings in Python are immutable, if you want to modify a single character in a string in Python, you need to do something like the following...
a = list("foo")
a[2] = 'x'
print ''.join(a)
The string "fox " will be printed out.
Simple environment variable usage in Linux
Answer:
In Linux, the most basic way to set an environment variable is use the "=" operator.
For example:
# foo=bar
# echo $foo
bar
Is Perl pass by reference or pass by value?
Answer:
(Edit: Thanks Matt for the feedback, I have updated the answer.)
It depends on how your function is implemented
See the code below:
package Dog;
sub new {
my ($class, $name) = @_;
my $self = { "name" => $name };
bless $self, $class;
return $self;
}
// Pass by value
sub Foo {
my $d = shift;
$d = new Dog("Another");
}
// Pass by reference
sub Bar {
$_[0] = new Dog("Another");
}
my $d = new Dog("Peter");
Foo($d); // Pass by value, $d not changed, so it print out "Peter"
print $d->{"name"};
Bar($d); // Pass by reference, $d is changed, so it print out "Another"
print $d->{"name"};
Set the maximum execution time in PHP
Answer:
The default maximum execution time in PHP is 30 seconds. If you want to change it, you need to edit the php.ini
vi /etc/php.ini
Locate and set
max_execution_time = 120;
Try it with the number you need.
Also, remember to restart web server such as Apache if needed.