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
21
votes
1 answer

Are Unix reads and writes to a single file atomically serialized?

I'd like to know if the writes upon a single file get done atomically such that write("bla bla") and a subsequent write("herp derp") to the same file never results in interleaving, e.g. "bla herp bla derp". Assuming these writes happen in different…
Jegschemesch
  • 11,414
  • 4
  • 32
  • 37
21
votes
4 answers

Send Ctrl-C to remote processes started via subprocess.Popen and ssh

How do I send a Ctrl-C to multiple ssh -t processes in Popen() objects? I have some Python code that kicks off a script on a remote host: # kickoff.py # i call 'ssh' w/ the '-t' flag so that when i press 'ctrl-c', it get's # sent to the script on…
aaronstacy
  • 6,189
  • 13
  • 59
  • 72
21
votes
1 answer

Inside a bash script, how to get PID from a program executed when using the eval command?

I have commands in a bash script that are similar to this: eval "( java -classpath ./ $classname ${arguments[@]} $redirection_options $file )" & pid=$! However if I do a ps $pid it shows the main script process instead of the process of the java…
Milo
  • 225
  • 1
  • 2
  • 5
21
votes
2 answers

Is it possible to keep the output of less on the screen after quitting?

I'm using oh-my-zsh which pipes the output of some functions like git diff and git log into less, whilst this is great for reading the output in the terminal. If I need to refer back to it it isn't possible after quitting with :q Is there an option…
Luke
  • 3,481
  • 6
  • 39
  • 63
21
votes
3 answers

Using sed to insert text at the beginning of each line

How would one go about using sed in order to insert rm -rf at the start of each line of a file?
THE DOCTOR
  • 4,399
  • 10
  • 43
  • 64
21
votes
5 answers

How to make a multi-character parameter in UNIX using getopt?

I'm trying to make a getopt command such that when I pass the "-ab" parameter to a script, that script will treat -ab as a single parameter. #!/bin/sh args=`getopt "ab":fc:d $*` set -- $args for i in $args do case "$i" in -ab) shift;echo…
Waffles
  • 447
  • 2
  • 5
  • 11
21
votes
2 answers

How to use C++ Boost library with pkg-config?

I successfully compiled and installed the latest version of the Boost library onto my linux machine. Now, I would like to be able to use pkg-config to ease the process of providing linking paremeters with GCC. Since I am too lazy for hand-coding my…
eold
  • 5,972
  • 11
  • 56
  • 75
21
votes
4 answers

Difference between $() and () in Bash

When I type ls -l $(echo file) output from bracket (which is just simple echo'ing) is taken and passed to external ls -l command. It equals to simple ls -l file. When I type ls -l (echo file) we have error because one cannot nest () inside external…
run4gnu
  • 333
  • 1
  • 2
  • 7
21
votes
3 answers

sshpass: command not found error

I am trying to automate the file transfer or FTP from one server to the other. #!/bin/bash ### In this model, the same filename is processed on each run. ### A timestamp is added to the result file and data file is copied to the archive or error…
sreekem bose
  • 451
  • 3
  • 12
  • 28
21
votes
4 answers

Ansible: Add Unix group to user only if the group exists

I'm using Ansible to add a user to a variety of servers. Some of the servers have different UNIX groups defined. I'd like to find a way for Ansible to check for the existence of a group that I specify, and if that group exists, add it to a User's…
Joe J
  • 9,985
  • 16
  • 68
  • 100
21
votes
3 answers

Filtering Rows Based On Number of Columns with AWK

I have lines of data that contain single column and two columns. What I want to do is to extract lines that contain only 2 columns. 0333 foo bar 23243 qux yielding only: 0333 foo 23243 qux Note that they are tab separated, even for lines with…
neversaint
  • 60,904
  • 137
  • 310
  • 477
21
votes
2 answers

What to do if a posix close call fails?

On my system (Ubuntu Linux, glibc), man page of a close call specifies several error return values it can return. It also says Not checking the return value of close() is a common but nevertheless serious programming error. and at the same…
Ilya Popov
  • 3,765
  • 1
  • 17
  • 30
21
votes
5 answers

unix command to read line from a file by passing line number

I am looking for a unix command to get a single line by passing line number to a big file (with around 5 million records). For example to get 10th line, I want to do something like command file-name 10 Is there any such command available? We can…
jgg
  • 1,136
  • 4
  • 22
  • 46
21
votes
3 answers

How to have different dependencies depending on OS family

I'm writing a cross-platform library that has platform specific dependencies, one for unix-like platforms, and one for windows. These crates only compile on specific platforms, wherefore I can't just add them all under dependencies normally. In the…
Bryal
  • 213
  • 2
  • 5
21
votes
2 answers

Difference between echo and @echo in unix shells

What's the difference between "echo" and "@echo" in the unix world? I can't even google special characters. For example, as used here
Mako
  • 271
  • 1
  • 3
  • 8