LINUX QUESTIONS MUST BE PROGRAMMING RELATED. Use this tag only if your question relates to programming using Linux APIs or Linux-specific behavior, not just because you happen to run your code on Linux. If you need Linux support you can try https://unix.stackexchange.com or https://askubuntu.com

921
votes
14answers
114k views

UTF-8 all the way through

I'm setting up a new server, and want to support UTF-8 fully in my web application. I have tried in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.Where ...
288
votes
3answers
78k views

Difference between single and double quotes in Bash

In Bash, what are the differences between single quotes ('') and double quotes ("")?
69
votes
4answers
18k views

When to wrap quotes around a shell variable?

Could someone tell me whether or not I should wrap quotes around variables in a shell script?For example, is the following correct:xdg-open $URL [ $? -eq 2 ]orxdg-open "$URL"[ "$?" -eq "2" ] ...
404
votes
9answers
246k views

Why does printf not flush after the call unless a newline is in the format string?

Why does printf not flush after the call unless a newline is in the format string? Is this POSIX behavior? How might I have printf immediately flush every time?
952
votes
13answers
1.1m views

How to set a variable to the output from a command in Bash?

I am working on a simple scripting project for work that involves the use of Bash. I have a pretty simple script that is something like the following:#!/bin/bashVAR1="$1"VAR2="$2"MOREF='sudo ...
34
votes
4answers
3k views

Why should there be a space after '[' and before ']' in Bash?

I was trying to write a Bash script that uses an if statement.if [$CHOICE -eq 1];The script was giving me errors until I gave a space after [ and before ] as shown below:if [ $CHOICE -eq 1 ];...
143
votes
6answers
295k views

How do I use shell variables in an awk script?

I found some ways to pass external shell variables to an awk script, but I'm confused about ' and ".First, I tried with a shell script:$ v=123test$ echo $v123test$ echo "$v"123testThen tried ...
204
votes
6answers
168k views

How to terminate a python subprocess launched with shell=True

I'm launching a subprocess with the following command:p=subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)However, when I try to kill using:p.terminate()or p.kill()The command ...
10
votes
2answers
13k views

Facing an error “*** glibc detected *** free(): invalid next size (fast)”

Please see MSO question A long list of possible duplicates — C memory allocation and overrunning bounds for information about closely related questions.Developer environment: CentOS 4.7, Kdevelop 3....
104
votes
7answers
97k views

Multiple glibc libraries on a single host

Multiple glibc libraries on a single hostMy linux (SLES-8) server currently has glibc-2.2.5-235, but I have a program which won't work on this version and requires glibc-2.3.3.Is it possible to ...
59
votes
3answers
20k views

printf anomaly after “fork()”

OS: Linux, Language: pure CI'm moving forward in learning C programming in general, and C programming under UNIX in a special case.I detected a strange (for me) behaviour of the printf() function ...
94
votes
4answers
72k views

What are the calling conventions for UNIX & Linux system calls on i386 and x86-64

Following links explain x86-32 system call conventions for both UNIX (BSD flavor) & Linux:http://www.int80h.org/bsdasm/#system-callshttp://www.freebsd.org/doc/en/books/developers-handbook/x86-...
63
votes
6answers
16k views

How to avoid using printf in a signal handler?

Since printf is not reentrant, it's not supposed to be safe to use it in a signal handler. But I've seen lots of example codes that uses printf this way.So my question is: when do we need to avoid ...
553
votes
26answers
427k views

Why doesn't “cd” work in a bash shell script?

I'm trying to write a small script to change the current directory to my project directory:#!/bin/bashcd /home/tree/projects/javaI saved this file as proj, added execute permission with chmod, ...
242
votes
8answers
214k views

What is the LD_PRELOAD trick?

I came across a reference to it recently on proggit and (as of now) it is not explained.I suspect this might be it, but I don't know for sure.

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,