Most Popular
1500 questions
77
votes
8 answers
Assigning exit code to a shell local variable
#!/bin/bash
function0()
{
local t1=$(exit 1)
echo $t1
}
function0
echo prints empty value. I expected:
1
Why doesn't t1 variable get assigned the exit command's return value - 1?
user93868
77
votes
5 answers
Can mouse wheel scrolling work in a Screen session?
Is there any way to use the mouse wheel to scroll through the output of a screen session?
I can use the keypad scroll through previous output in screen after pressing ctrl+a [. Is it possible to do this with the mouse wheel?
(I'm using putty, but I…

kristi
- 871
77
votes
4 answers
Limit grep context to N characters on line
I have to grep through some JSON files in which the line lengths exceed a few thousand characters. How can I limit grep to display context up to N characters to the left and right of the match? Any tool other than grep would be fine as well, so long…

dotancohen
- 15,864
77
votes
8 answers
How to disable SSLv3 in Apache?
Everybody seems to be talking about the POODLE vulnerability today. And everybody recommends disabling SSLv3 in Apache using the following configuration directive:
SSLProtocol All -SSLv2 -SSLv3
instead of the default
SSLProtocol All -SSLv2
I've…

Bogdan Stăncescu
- 911
77
votes
7 answers
How to dump a man page?
How can I 'cat' a man page like I would 'cat' a file to get just a dump of the contents?

LanceBaynes
- 40,135
- 97
- 255
- 351
77
votes
4 answers
Why doesn't the tilde (~) expand inside double quotes?
According to this answer and my own understanding, the tilde expands to the home directory:
$ echo ~
/home/braiam
Now, whenever I want the shell expansion to work, i. e. using variable names such $FOO, and do not break due unexpected characters,…

Braiam
- 35,991
77
votes
2 answers
Getting "Not found" message when running a 32-bit binary on a 64-bit system
I have currently a strange problem on debian (wheezy/amd64).
I have created a chroot to install a server (i can't give any more detail about it, sorry). Let's call its path /chr_path/.
To make things easy, I have initialized this chroot with a…

Elenaher
- 949
77
votes
4 answers
How can I test the encoding of a text file... Is it valid, and what is it?
I have several .htm files which open in Gedit without any warning/error, but when I open these same files in Jedit, it warns me of invalid UTF-8 encoding...
The HTML meta tag states "charset=ISO-8859-1". Jedit allows a List of fallback encodings and…

Peter.O
- 32,916
76
votes
6 answers
How to check if Bash can print colors
I want to know if there's any way to check if my program can output terminal output using colors or not.
Running commands like less and looking at the output from a program that outputs using colors, the output is displayed incorrectly, like…

Angelo Vargas
- 873
76
votes
10 answers
How to allow non-superusers to mount any filesystem?
Is it possible to allow some particular users (e.g. members of a group) to mount any filesystem without superuser privileges on Linux?
Another question might have been "in what ways a user can harm a system by mounting filesystems?"
user27225
76
votes
5 answers
How to convert floating point number to integer?
Is this the right way to do float to integer conversion in bash? Is there any other method?
flotToint() {
printf "%.0f\n" "$@"
}

Rahul Patil
- 24,711
76
votes
6 answers
Concatenating two variables with an underscore
I need to concatenate two variables to create a filename that has an underscore.
Lets call my variables $FILENAME and $EXTENSION where filename is read from a file.
FILENAME=Hello
EXTENSION=WORLD.txt
Now...
I have tried the following without…

Rhyuk
- 1,115
76
votes
6 answers
Differences between volume, partition and drive
What do these terms mean exactly?
partition
volume
drive
On Windows, one may say drive C: or partition C:. On Linux I'm not sure what should be used for partitions because they don't have a name.
user44920
76
votes
4 answers
How can I remove an element from an array completely?
unset array[0] removes the element but still if I do echo ${array[0]} I get a null value moreover there are other ways of doing this but if an element of an array contains spaces like below
array[0]='james young'
array[1]='mary'
array[2]='randy…

munish
- 7,987
76
votes
2 answers
pwd without symlinks
If I do pwd I notice it uses whatever symlinks I used to get into the current directory. Can I get it to tell me the "real" directory I'm in ... i.e. the path from the root to my current directory without the use of any symlinks?

JoelFan
- 1,329