Questions tagged [unix]

NOTICE: All Unix questions must be related to programming; those that aren't will be closed. Use this tag only if your question relates to programming using Unix APIs or Unix-specific behavior, not just because you happen to run your code on Unix. General software issues should be directed to Unix & Linux Stack Exchange or to Super User.

Tag usage

The tag can be used for Unix system programming related problems. The tag can also contain programming questions about using the Unix platform. For non-programming Unix usage questions, visit the Unix & Linux Stack Exchange site.

Background

Unix was developed as an in-house operating system for AT&T, but in the 1980s became both a prime academic operating system (with U.C. Berkeley's version, called BSD, being the reference platform for development of what would become the Internet) and a commercial success in the form of AT&T's System V, Microsoft/SCO's XENIX (PCs) and various workstation versions from Sun, Silicon Graphics, and others.

In the 1990s, Sun's Solaris and the free Unix clone Linux would rise in popularity. Linux is largely Unix-compatible but lacks the trademark. Currently, Unix is commonly found on server platforms; the primary desktop variant is Mac OS X, based on BSD.

Apart from its command-line interface, most "Unices" support the standardized X Window System for GUIs. (So does Mac OS X, but its primary GUI is Apple's proprietary Quartz.)

The various Unix implementation (and to a lesser extent, clones such as Linux) are unified in a standard called POSIX. C has been its primary programming language since the 1970s, but many other languages are available.

Read more

47509 questions
22
votes
6 answers

UNIX Programming. struct timeval how to print it (C-programming)

I am trying to print a value of type timeval. Actually I am able to print it, but I get the following warning: Multiple markers at this line format ‘%ld’ expects type ‘long int’, but argument 2 has type ‘struct timeval’ The program compiles and it…
user69514
  • 26,935
  • 59
  • 154
  • 188
22
votes
5 answers

difference between grep Vs cat and grep

i would like to know difference between below 2 commands, I understand that 2) should be use but i want to know the exact sequence that happens in 1) and 2) suppose filename has 200 characters in it 1) cat filename | grep regex 2) grep regex…
unixadmin007
  • 221
  • 1
  • 2
  • 3
22
votes
5 answers

Installing pip for python3.3

I downloaded pip from Package Index > pip 1.2.1 Then I installed it using sudo python3.3 setup.py install Still, when I try to use pip-3.3 the terminal complains -bash: pip-3.3: command not found However, pip-2.7 works swimmingly. I have also…
The Unfun Cat
  • 29,987
  • 31
  • 114
  • 156
22
votes
2 answers

Print a variable with multi-line value in shell?

In Bash (or other shells) how can I print an environment variable which has a multi-line value? text='line1 line2' I know a simple usual echo $text won't work out of the box. Would some $IFS tweak help? My current workaround is something like ruby…
inger
  • 19,574
  • 9
  • 49
  • 54
22
votes
6 answers

Why do my keystrokes turn into crazy characters after I dump a bunch of binary data into my terminal?

If I do something like: $ cat /bin/ls into my terminal, I understand why I see a bunch of binary data, representing the ls executable. But afterwards, when I get my prompt back, my own keystrokes look crazy. I type "a" and I get a weird diagonal…
raldi
  • 21,344
  • 33
  • 76
  • 86
22
votes
5 answers

Python scripts in /usr/bin

I'm writing a pretty basic application in python (it's only one file at the moment). My question is how do I get it so the python script is able to be run in /usr/bin without the .py extension? For example, instead of running python htswap.py…
Steve Gattuso
  • 7,644
  • 10
  • 44
  • 59
22
votes
1 answer

Crontab every 5 minutes

How could i tell crontab to run every 5 minutes, but starting at the second minute of the hour. In other words, i would like to execute my script when minute % 5 = 2. For example, my script should run at : 08:02 08:07 08:12 08:17 ... Thanks for…
Arnaud
  • 7,259
  • 10
  • 50
  • 71
22
votes
7 answers

What is the difference between := and += in make file?

what is working difference in the below statements? LDDIRS := -L$(ORACLE_LIB) LDDIRS += -L$(ORACLE_LIB)
Naina B
  • 321
  • 1
  • 2
  • 7
21
votes
2 answers

chdir() to home directory

I am using the chdir() C function to allow a user to change directory. The function however, doesn't recognize '~'. Do I need to do any explicit conversion, so chdir doesn't recognize what ~ means? Because mine isn't working. Or am I doing something…
darksky
  • 20,411
  • 61
  • 165
  • 254
21
votes
5 answers

Run Another Program in Linux from a C++ Program

Okay so my question is this. Say I have a simple C++ code: #include using namespace std; int main(){ cout << "Hello World" << endl; return 0; } Now say I have this program that I would like to run in my program, call it prog.…
Vincent Russo
  • 1,087
  • 3
  • 20
  • 33
21
votes
4 answers

Why does \$ reduce to $ inside backquotes [though not inside $(...)]?

Going over the POSIX standard, I came across another rather technical/pointless question. It states: Within the backquoted style of command substitution, shall retain its literal meaning, except when followed by: '$' , '`' , or…
ezequiel-garzon
  • 3,047
  • 6
  • 29
  • 33
21
votes
6 answers

Longjmp out of signal handler?

From the question: Is it good programming practice to use setjmp and longjmp in C? Two of the comments left said: "You can't throw an exception in a signal handler, but you can do a longjmp safely -- as long as you know what you are doing. –…
John Humphreys
  • 37,047
  • 37
  • 155
  • 255
21
votes
4 answers

Python exit codes

Where can I find information about meaning of exit codes of "python" process on Unix? For instance, if I do "python thisfiledoesntexist.py", I get exit code 2 Summary: from errno import errorcode print errorcode[2]
Yaroslav Bulatov
  • 57,332
  • 22
  • 139
  • 197
21
votes
4 answers

Using dlopen() on an executable

I need to call a function from another program. If the other program were a library, I could simply use dlopen and dlsym to get a handle to the function. Unfortunately, the other program is a Unix Executable, and building it as a library is not an…
Jeff
  • 2,149
  • 3
  • 17
  • 19
21
votes
6 answers

execve file not found when stracing the very same file!

someone i know encountered a problem when running 'lmutil' so i asked them to strace -f lmutil. Why is execve failing with "No such file"!!! It makes no sense, since I am straceing the very same file!! What exactly is going on here??? strace -f…
user621819