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

PHP: get_current_user() vs. exec('whoami')

Short version of the question: What's the difference between get_current_user(); and exec('whoami'); ? Long version of the question: I'm on a XAMPP Localhost on a Mac. I'm using Apache, building a PHP based website in a folder (let's call it…
thanks_in_advance
  • 2,603
  • 6
  • 28
  • 44
21
votes
7 answers

Is there a java library equivalent to file command in unix

Is there any java library that is similar to unix's command file? ie: $ file somepicture.png somepicture.png PNG image, 805 x 292, 8-bit/color RGB, non-interlaced The file command is such a nice tool. I need something that can tell me if the file…
Shervin Asgari
  • 23,901
  • 30
  • 103
  • 143
21
votes
4 answers

starting smartcard programming

How could one get started with smartcards programming? I am asking here about all the toolkit he needs in order to get started: books, tutorials, hardware etc. I am planning in playing around with a couple of smartcards programmers and I am pretty…
hyperboreean
  • 8,273
  • 12
  • 61
  • 97
21
votes
5 answers

Signal Handling in C

How can I implement signal Handling for Ctrl-C and Ctrl-D in C....So If Ctrl-C is pressed then the program will ignore and try to get the input from the user again...If Ctrl-D is pressed then the program will terminate... My program follows: int…
Dave
  • 211
  • 1
  • 2
  • 3
21
votes
3 answers

binary operator expected error when checking if a file with full pathname exists

pathname=$(cat $HOME/.rm.cfg) if [ ! -z $pathname/$1 ] .rm.cfg is a file that contains the following directory /home/username/deleted1 $1 is the name of a file eg. glass why does the line if [ ! -z $pathname/$1 ] give a binary operator expected…
user3809938
  • 1,114
  • 3
  • 16
  • 35
21
votes
5 answers

Rename file command in Unix with timestamp

Hello I'm using Putty and trying to rename a file name with current timestamp. I've used following command to rename the files and according to date mv abc.log $(date +%F)prod.txt Above command renames but not able to rename with time, it giving…
PavanBasutkar
  • 237
  • 1
  • 2
  • 5
21
votes
8 answers

Why and when to use the shell instead of Ruby

Since I am conversant in Ruby, I am about to script a few things on OS X using it. But then I thought, perhaps I am missing the boat. I know a lot of reasons to prefer Ruby over Bash (or whatever sh-compatible command language interpreter), but I…
Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
21
votes
1 answer

Does exec preserve file descriptors

This is actually a two-step question: What exactly is a file descriptor? I thought it was the most fundamental way to represent an open file. But since dup2 can make two different file descriptors point to the same file, then what is it that…
Xufeng
  • 6,452
  • 8
  • 24
  • 30
21
votes
5 answers

why is this simple FOR LOOP in my Linux bash not working?

I'm trying to do a simple for loop in a UNIX script (bash). Here's my script: for i in {1..3} do echo "Welcome $i times" done I was expecting this for output ... Welcome 1 times Welcome 2 times Welcome 3 times ... but I get this ... Welcome…
user550738
21
votes
2 answers

Copying local files with curl

Is there a way to copy local files with curl, I need it to work as an alternative for cp command. This is a bit strange, but I'm working on an environment where cp is not available.
zibi
  • 3,183
  • 3
  • 27
  • 47
21
votes
1 answer

Permissions required to move file to different directory in Unix/Linux

I would like clarification on the permissions required, in order to move a file A from directory B to directory C (the command would be "mv B/A C/A", I think), with name unchanged. Am I correct to think that the following are required? The…
Andy
  • 2,770
  • 9
  • 35
  • 42
21
votes
1 answer

Is there a python-equivalent of the unix "file" utility?

I want to have different behavior in a python script, depending on the type of file. I cannot use the filename extension as it may not be present or misleading. I could call the file utility and parse the output, but I would rather use a python…
0x89
  • 2,940
  • 2
  • 31
  • 30
21
votes
4 answers

Fastest way of finding differences between two files in unix?

I want to find the difference between two files and then put only the differences in a third file. I saw different approaches using awk, diff and comm. Are there any more ? eg.Compare two files line by line and generate the difference in another…
Steam
  • 9,368
  • 27
  • 83
  • 122
21
votes
3 answers

Why are UNIX file descriptors not implemented by their own type, especially in C++?

I've been using a fair amount of file descriptors recently, and I've been wondering why they're implemented as integers? It means that they're easy to confuse for other integers, and there's no way of knowing without context what they are, what they…
allicoder
  • 285
  • 1
  • 7
21
votes
2 answers

Postgres locale error

I have a Postgres database hosted on Digital River, on Ubuntu, and followed these instructions to install: But something is wrong with the locale settings and I cannot work out how to fix it. When I run the psql command I get the following…
port5432
  • 5,889
  • 10
  • 60
  • 97